MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / ecall_encrypt

Function ecall_encrypt

sgx_tf_ops/Enclave/Enclave.cpp:181–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181void ecall_encrypt(float *input, int N, float *output){
182 float mean = 0.0f, std, mean_sqr = 0.0f;
183 float c_mean = 0.0f, c_mean_sqr = 0.0f;
184 for (int j = 0; j < N; j++) {
185 float y = (input[j] /static_cast<float>(N)) - c_mean;
186 float t = mean + y;
187 c_mean = (t - mean) - y;
188 mean = t;
189
190 float y2 = (input[j]*input[j]/static_cast<float>(N)) - c_mean_sqr;
191 float t2 = mean_sqr + y2;
192 c_mean_sqr = (t2 - mean_sqr) - y2;
193 mean_sqr = t2;
194 }
195 std = sqrtf(fabs(mean_sqr - mean * mean))/static_cast<float>(Nt);
196 mean = mean/static_cast<float>(Nt);
197 for(int i=0;i<N*(Ne-1);i++){
198 output[i] =(input[i % N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
199 }
200 for(int j=N*(Ne-1);j<N*Ne;j++){
201 output[j] = 0.0f;
202 float sum = input[j-N*(Ne-1)];
203 float c = 0.0f;
204 for(int i=0;i<Nt;i++){
205 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
206 float t = sum + y;
207 c = (t - sum) - y;
208 sum = t;
209 }
210 output[j] = sum;
211 }
212 return;
213}
214
215void ecall_decrypt(float *input,int N, float *output){
216 for(int j=0;j<N;j++){

Callers 1

encrypt1Function · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected