@reclaimprotocol/attestor-core 5.0.1-beta.2 → 5.0.1-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/resources/attestor-browser.min.mjs +4512 -0
- package/lib/avs/abis/avsDirectoryABI.js +338 -341
- package/lib/avs/abis/delegationABI.js +1 -4
- package/lib/avs/abis/registryABI.js +719 -722
- package/lib/avs/client/create-claim-on-avs.js +129 -157
- package/lib/avs/config.js +18 -24
- package/lib/avs/contracts/ReclaimServiceManager.js +1 -0
- package/lib/avs/contracts/common.js +1 -0
- package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +1139 -1156
- package/lib/avs/contracts/factories/index.js +4 -4
- package/lib/avs/contracts/index.js +2 -6
- package/lib/avs/types/index.js +1 -0
- package/lib/avs/utils/contracts.js +30 -50
- package/lib/avs/utils/register.js +75 -70
- package/lib/avs/utils/tasks.js +38 -45
- package/lib/client/create-claim.js +402 -431
- package/lib/client/tunnels/make-rpc-tcp-tunnel.js +46 -48
- package/lib/client/tunnels/make-rpc-tls-tunnel.js +125 -121
- package/lib/client/utils/attestor-pool.js +23 -22
- package/lib/client/utils/client-socket.js +86 -109
- package/lib/client/utils/message-handler.js +79 -89
- package/lib/config/index.js +40 -58
- package/lib/external-rpc/benchmark.js +61 -74
- package/lib/external-rpc/event-bus.js +12 -15
- package/lib/external-rpc/handle-incoming-msg.js +216 -225
- package/lib/external-rpc/jsc-polyfills/1.js +70 -68
- package/lib/external-rpc/jsc-polyfills/2.js +17 -12
- package/lib/external-rpc/jsc-polyfills/event.js +10 -15
- package/lib/external-rpc/jsc-polyfills/index.js +2 -2
- package/lib/external-rpc/jsc-polyfills/ws.js +77 -79
- package/lib/external-rpc/setup-browser.js +28 -28
- package/lib/external-rpc/setup-jsc.js +17 -17
- package/lib/external-rpc/types.js +1 -0
- package/lib/external-rpc/utils.js +89 -89
- package/lib/external-rpc/zk.js +55 -50
- package/lib/index.js +2 -6
- package/lib/mechain/abis/governanceABI.js +457 -460
- package/lib/mechain/abis/taskABI.js +502 -505
- package/lib/mechain/client/create-claim-on-mechain.js +24 -29
- package/lib/mechain/constants/index.js +3 -8
- package/lib/mechain/types/index.js +1 -0
- package/lib/proto/api.js +4200 -4087
- package/lib/proto/tee-bundle.js +1261 -1241
- package/lib/providers/http/index.js +616 -603
- package/lib/providers/http/patch-parse5-tree.js +27 -29
- package/lib/providers/http/utils.js +289 -248
- package/lib/providers/index.js +3 -6
- package/lib/server/create-server.js +89 -91
- package/lib/server/handlers/claimTeeBundle.js +231 -211
- package/lib/server/handlers/claimTunnel.js +66 -73
- package/lib/server/handlers/completeClaimOnChain.js +20 -25
- package/lib/server/handlers/createClaimOnChain.js +21 -27
- package/lib/server/handlers/createTaskOnMechain.js +40 -50
- package/lib/server/handlers/createTunnel.js +85 -90
- package/lib/server/handlers/disconnectTunnel.js +4 -7
- package/lib/server/handlers/fetchCertificateBytes.js +37 -53
- package/lib/server/handlers/index.js +21 -24
- package/lib/server/handlers/init.js +27 -28
- package/lib/server/handlers/toprf.js +13 -16
- package/lib/server/socket.js +97 -100
- package/lib/server/tunnels/make-tcp-tunnel.js +161 -186
- package/lib/server/utils/apm.js +32 -25
- package/lib/server/utils/assert-valid-claim-request.js +305 -334
- package/lib/server/utils/config-env.js +2 -2
- package/lib/server/utils/dns.js +12 -18
- package/lib/server/utils/gcp-attestation.js +233 -181
- package/lib/server/utils/generics.d.ts +1 -1
- package/lib/server/utils/generics.js +43 -37
- package/lib/server/utils/iso.js +253 -256
- package/lib/server/utils/keep-alive.js +36 -36
- package/lib/server/utils/nitro-attestation.js +295 -220
- package/lib/server/utils/oprf-raw.js +48 -55
- package/lib/server/utils/process-handshake.js +200 -218
- package/lib/server/utils/proxy-session.js +5 -5
- package/lib/server/utils/tee-oprf-mpc-verification.js +82 -78
- package/lib/server/utils/tee-oprf-verification.js +165 -142
- package/lib/server/utils/tee-transcript-reconstruction.js +176 -129
- package/lib/server/utils/tee-verification.js +397 -334
- package/lib/server/utils/validation.js +30 -37
- package/lib/types/bgp.js +1 -0
- package/lib/types/claims.js +1 -0
- package/lib/types/client.js +1 -0
- package/lib/types/general.js +1 -0
- package/lib/types/handlers.js +1 -0
- package/lib/types/providers.d.ts +3 -2
- package/lib/types/providers.gen.js +9 -15
- package/lib/types/providers.js +1 -0
- package/lib/types/rpc.js +1 -0
- package/lib/types/signatures.d.ts +1 -2
- package/lib/types/signatures.js +1 -0
- package/lib/types/tunnel.js +1 -0
- package/lib/types/zk.js +1 -0
- package/lib/utils/auth.js +54 -66
- package/lib/utils/b64-json.js +15 -15
- package/lib/utils/bgp-listener.js +107 -111
- package/lib/utils/claims.js +89 -80
- package/lib/utils/env.js +13 -17
- package/lib/utils/error.js +43 -47
- package/lib/utils/generics.js +284 -235
- package/lib/utils/http-parser.js +232 -187
- package/lib/utils/logger.js +80 -71
- package/lib/utils/prepare-packets.js +69 -67
- package/lib/utils/redactions.js +163 -121
- package/lib/utils/retries.js +22 -24
- package/lib/utils/signatures/eth.js +29 -28
- package/lib/utils/signatures/index.js +5 -10
- package/lib/utils/socket-base.js +84 -88
- package/lib/utils/tls.js +28 -28
- package/lib/utils/ws.js +19 -19
- package/lib/utils/zk.js +542 -582
- package/package.json +12 -5
- package/lib/external-rpc/global.d.js +0 -0
- package/lib/scripts/build-browser.d.ts +0 -1
- package/lib/scripts/build-jsc.d.ts +0 -1
- package/lib/scripts/build-lib.d.ts +0 -1
- package/lib/scripts/check-avs-registration.d.ts +0 -1
- package/lib/scripts/check-avs-registration.js +0 -28
- package/lib/scripts/fallbacks/crypto.d.ts +0 -1
- package/lib/scripts/fallbacks/crypto.js +0 -4
- package/lib/scripts/fallbacks/empty.d.ts +0 -3
- package/lib/scripts/fallbacks/empty.js +0 -4
- package/lib/scripts/fallbacks/re2.d.ts +0 -1
- package/lib/scripts/fallbacks/re2.js +0 -7
- package/lib/scripts/fallbacks/snarkjs.d.ts +0 -1
- package/lib/scripts/fallbacks/snarkjs.js +0 -10
- package/lib/scripts/fallbacks/stwo.d.ts +0 -6
- package/lib/scripts/fallbacks/stwo.js +0 -159
- package/lib/scripts/generate-provider-types.d.ts +0 -5
- package/lib/scripts/generate-provider-types.js +0 -101
- package/lib/scripts/generate-receipt.d.ts +0 -9
- package/lib/scripts/generate-receipt.js +0 -101
- package/lib/scripts/generate-toprf-keys.d.ts +0 -1
- package/lib/scripts/generate-toprf-keys.js +0 -24
- package/lib/scripts/jsc-cli-rpc.d.ts +0 -1
- package/lib/scripts/jsc-cli-rpc.js +0 -35
- package/lib/scripts/register-avs-operator.d.ts +0 -1
- package/lib/scripts/register-avs-operator.js +0 -3
- package/lib/scripts/start-server.d.ts +0 -1
- package/lib/scripts/start-server.js +0 -11
- package/lib/scripts/update-avs-metadata.d.ts +0 -1
- package/lib/scripts/update-avs-metadata.js +0 -20
- package/lib/scripts/utils.d.ts +0 -1
- package/lib/scripts/utils.js +0 -10
- package/lib/scripts/whitelist-operator.d.ts +0 -1
- package/lib/scripts/whitelist-operator.js +0 -16
|
@@ -1,151 +1,174 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TEE OPRF Verification and Replacement
|
|
3
|
+
* Verifies OPRF proofs and replaces ranges in reconstructed plaintext
|
|
4
|
+
*/
|
|
5
|
+
import bs58 from 'bs58';
|
|
2
6
|
import { AttestorError } from "../../utils/error.js";
|
|
3
7
|
import { makeDefaultOPRFOperator } from "../../utils/zk.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!consolidatedCiphertext || consolidatedCiphertext.length === 0) {
|
|
12
|
-
throw new AttestorError("ERROR_INVALID_CLAIM", "No consolidated ciphertext for OPRF verification");
|
|
13
|
-
}
|
|
14
|
-
const results = [];
|
|
15
|
-
logger.info(`Verifying ${bundleData.oprfVerifications.length} OPRF proofs`);
|
|
16
|
-
for (const [idx, oprfData] of bundleData.oprfVerifications.entries()) {
|
|
17
|
-
try {
|
|
18
|
-
const result = await verifySingleOprfProof(
|
|
19
|
-
oprfData,
|
|
20
|
-
consolidatedCiphertext,
|
|
21
|
-
idx,
|
|
22
|
-
logger
|
|
23
|
-
);
|
|
24
|
-
results.push(result);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error({ error, index: idx }, "OPRF proof verification failed");
|
|
27
|
-
throw new AttestorError(
|
|
28
|
-
"ERROR_INVALID_CLAIM",
|
|
29
|
-
`OPRF verification failed at index ${idx}: ${error.message}`
|
|
30
|
-
);
|
|
8
|
+
/**
|
|
9
|
+
* Verifies all OPRF proofs in the bundle and returns replacement data
|
|
10
|
+
*/
|
|
11
|
+
export async function verifyOprfProofs(bundleData, logger) {
|
|
12
|
+
if (!bundleData.oprfVerifications || bundleData.oprfVerifications.length === 0) {
|
|
13
|
+
logger.debug('No OPRF verifications present in bundle');
|
|
14
|
+
return [];
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
const { tOutputPayload } = bundleData;
|
|
17
|
+
const consolidatedCiphertext = tOutputPayload.consolidatedResponseCiphertext;
|
|
18
|
+
if (!consolidatedCiphertext || consolidatedCiphertext.length === 0) {
|
|
19
|
+
throw new AttestorError('ERROR_INVALID_CLAIM', 'No consolidated ciphertext for OPRF verification');
|
|
20
|
+
}
|
|
21
|
+
const results = [];
|
|
22
|
+
logger.info(`Verifying ${bundleData.oprfVerifications.length} OPRF proofs`);
|
|
23
|
+
for (const [idx, oprfData] of bundleData.oprfVerifications.entries()) {
|
|
24
|
+
try {
|
|
25
|
+
const result = await verifySingleOprfProof(oprfData, consolidatedCiphertext, idx, logger);
|
|
26
|
+
results.push(result);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger.error({ error, index: idx }, 'OPRF proof verification failed');
|
|
30
|
+
throw new AttestorError('ERROR_INVALID_CLAIM', `OPRF verification failed at index ${idx}: ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
logger.info(`Successfully verified ${results.length} OPRF proofs`);
|
|
34
|
+
return results;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Verifies a single OPRF proof and extracts the output
|
|
38
|
+
*/
|
|
36
39
|
async function verifySingleOprfProof(oprfData, consolidatedCiphertext, index, logger) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
oprfData.streamPos + oprfData.streamLength
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
40
|
+
// Parse public signals JSON
|
|
41
|
+
const publicSignalsJson = JSON.parse(new TextDecoder().decode(oprfData.publicSignalsJson));
|
|
42
|
+
const { proof, publicSignals, cipher } = publicSignalsJson;
|
|
43
|
+
if (!proof || !publicSignals) {
|
|
44
|
+
throw new Error('Missing proof or public signals in OPRF data');
|
|
45
|
+
}
|
|
46
|
+
// Extract ciphertext chunk for verification
|
|
47
|
+
const ciphertextChunk = consolidatedCiphertext.slice(oprfData.streamPos, oprfData.streamPos + oprfData.streamLength);
|
|
48
|
+
// Build complete public signals for verification
|
|
49
|
+
// Start with original signals and override specific fields
|
|
50
|
+
const completePublicSignals = {
|
|
51
|
+
out: publicSignals.out || Uint8Array.from([]),
|
|
52
|
+
// Replace null input with extracted ciphertext
|
|
53
|
+
in: ciphertextChunk,
|
|
54
|
+
// Convert base64 nonces and counters
|
|
55
|
+
noncesAndCounters: publicSignals.blocks?.map((block) => ({
|
|
56
|
+
nonce: Buffer.from(block.nonce || '', 'base64'),
|
|
57
|
+
counter: block.counter || 0,
|
|
58
|
+
boundary: block.boundary || '',
|
|
59
|
+
})) || [],
|
|
60
|
+
// Process TOPRF data
|
|
61
|
+
toprf: publicSignals.toprf ? {
|
|
62
|
+
...publicSignals.toprf,
|
|
63
|
+
// Convert domain separator from base64
|
|
64
|
+
domainSeparator: publicSignals.toprf.domainSeparator ?
|
|
65
|
+
Buffer.from(publicSignals.toprf.domainSeparator, 'base64').toString('utf8') :
|
|
66
|
+
'reclaim',
|
|
67
|
+
// Convert output from base64
|
|
68
|
+
output: publicSignals.toprf.output ?
|
|
69
|
+
Buffer.from(publicSignals.toprf.output, 'base64') :
|
|
70
|
+
new Uint8Array(),
|
|
71
|
+
// Convert response fields from base64
|
|
72
|
+
responses: publicSignals.toprf.responses?.map((resp) => ({
|
|
73
|
+
publicKeyShare: Buffer.from(resp.publicKeyShare || '', 'base64'),
|
|
74
|
+
evaluated: Buffer.from(resp.evaluated || '', 'base64'),
|
|
75
|
+
c: Buffer.from(resp.c || '', 'base64'),
|
|
76
|
+
r: Buffer.from(resp.r || '', 'base64')
|
|
77
|
+
})) || [],
|
|
78
|
+
// Locations are already in correct format
|
|
79
|
+
locations: publicSignals.toprf.locations || []
|
|
80
|
+
} : undefined
|
|
81
|
+
};
|
|
82
|
+
// Determine algorithm from cipher field
|
|
83
|
+
// Remove '-toprf' suffix but keep the rest of the algorithm name
|
|
84
|
+
const algorithm = cipher.replace('-toprf', '');
|
|
85
|
+
const zkEngine = 'gnark'; // Default to gnark for server-side verification
|
|
86
|
+
// Get OPRF operator for verification
|
|
87
|
+
const oprfOperator = makeDefaultOPRFOperator(algorithm, zkEngine, logger);
|
|
88
|
+
// Convert proof from base64
|
|
89
|
+
const proofBytes = Buffer.from(proof, 'base64');
|
|
90
|
+
// Verify the proof
|
|
91
|
+
const isValid = await oprfOperator.groth16Verify(completePublicSignals, proofBytes, logger);
|
|
92
|
+
if (!isValid) {
|
|
93
|
+
throw new Error('OPRF proof verification failed');
|
|
94
|
+
}
|
|
95
|
+
logger.debug(`OPRF ${index}: Proof verified successfully`);
|
|
96
|
+
// Extract OPRF output for replacement
|
|
97
|
+
const oprfOutput = completePublicSignals.toprf?.output;
|
|
98
|
+
if (!oprfOutput || oprfOutput.length === 0) {
|
|
99
|
+
throw new Error('No OPRF output found in verified proof');
|
|
100
|
+
}
|
|
101
|
+
// Get the actual location within the stream where OPRF data resides
|
|
102
|
+
const oprfLocation = completePublicSignals.toprf?.locations?.[0];
|
|
103
|
+
if (!oprfLocation) {
|
|
104
|
+
throw new Error('No OPRF location found in public signals');
|
|
105
|
+
}
|
|
106
|
+
// Log position calculation
|
|
107
|
+
logger.info(`OPRF #${index}: streamPos=${oprfData.streamPos}, locationPos=${oprfLocation.pos}, finalPos=${oprfData.streamPos + oprfLocation.pos}, len=${oprfLocation.len}`);
|
|
108
|
+
return {
|
|
109
|
+
// The position in the plaintext where to replace (stream position + OPRF location within chunk)
|
|
110
|
+
position: oprfData.streamPos + oprfLocation.pos,
|
|
111
|
+
length: oprfLocation.len,
|
|
112
|
+
output: oprfOutput
|
|
113
|
+
};
|
|
102
114
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Replaces OPRF ranges in the reconstructed plaintext with verified outputs.
|
|
117
|
+
* Properly expands or contracts the transcript to fit replacement hashes.
|
|
118
|
+
*/
|
|
119
|
+
export function replaceOprfRanges(plaintext, oprfResults, logger) {
|
|
120
|
+
if (oprfResults.length === 0) {
|
|
121
|
+
return plaintext;
|
|
122
|
+
}
|
|
123
|
+
const replacements = oprfResults.map(result => {
|
|
124
|
+
let outputBytes;
|
|
125
|
+
let encodedOutput;
|
|
126
|
+
if (result.isMPC) {
|
|
127
|
+
// MPC OPRF: use base58 encoding, full hash length (no truncation)
|
|
128
|
+
encodedOutput = bs58.encode(result.output);
|
|
129
|
+
outputBytes = new TextEncoder().encode(encodedOutput);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// TOPRF: use base64 encoding, truncate to fit original data length
|
|
133
|
+
encodedOutput = Buffer.from(result.output).toString('base64');
|
|
134
|
+
const truncated = encodedOutput.substring(0, result.length);
|
|
135
|
+
outputBytes = new TextEncoder().encode(truncated);
|
|
136
|
+
}
|
|
137
|
+
return { result, outputBytes, encodedOutput };
|
|
138
|
+
});
|
|
139
|
+
// Sort by position (ascending) to process in order
|
|
140
|
+
replacements.sort((a, b) => a.result.position - b.result.position);
|
|
141
|
+
// Calculate new transcript size
|
|
142
|
+
let newSize = plaintext.length;
|
|
143
|
+
for (const { result, outputBytes } of replacements) {
|
|
144
|
+
const sizeDiff = outputBytes.length - result.length;
|
|
145
|
+
newSize += sizeDiff;
|
|
146
|
+
}
|
|
147
|
+
logger.info(`Transcript size: ${plaintext.length} -> ${newSize} (${newSize - plaintext.length >= 0 ? '+' : ''}${newSize - plaintext.length} bytes)`);
|
|
148
|
+
// Build new transcript by copying segments and inserting replacements
|
|
149
|
+
const newPlaintext = new Uint8Array(newSize);
|
|
150
|
+
let srcPos = 0; // Position in original plaintext
|
|
151
|
+
let dstPos = 0; // Position in new plaintext
|
|
152
|
+
for (const [idx, { result, outputBytes, encodedOutput }] of replacements.entries()) {
|
|
153
|
+
// Copy segment before this replacement
|
|
154
|
+
const segmentLength = result.position - srcPos;
|
|
155
|
+
if (segmentLength > 0) {
|
|
156
|
+
newPlaintext.set(plaintext.slice(srcPos, result.position), dstPos);
|
|
157
|
+
dstPos += segmentLength;
|
|
158
|
+
}
|
|
159
|
+
// Log replacement
|
|
160
|
+
const currentContent = plaintext.slice(result.position, result.position + result.length);
|
|
161
|
+
logger.info(`OPRF #${idx} at pos ${result.position}: "${Buffer.from(currentContent).toString('utf8')}" (${result.length}b) -> "${encodedOutput}" (${outputBytes.length}b)${result.isMPC ? ' [MPC/base58]' : ''}`);
|
|
162
|
+
// Insert replacement hash
|
|
163
|
+
newPlaintext.set(outputBytes, dstPos);
|
|
164
|
+
dstPos += outputBytes.length;
|
|
165
|
+
// Move source position past the replaced range
|
|
166
|
+
srcPos = result.position + result.length;
|
|
117
167
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let newSize = plaintext.length;
|
|
122
|
-
for (const { result, outputBytes } of replacements) {
|
|
123
|
-
const sizeDiff = outputBytes.length - result.length;
|
|
124
|
-
newSize += sizeDiff;
|
|
125
|
-
}
|
|
126
|
-
logger.info(`Transcript size: ${plaintext.length} -> ${newSize} (${newSize - plaintext.length >= 0 ? "+" : ""}${newSize - plaintext.length} bytes)`);
|
|
127
|
-
const newPlaintext = new Uint8Array(newSize);
|
|
128
|
-
let srcPos = 0;
|
|
129
|
-
let dstPos = 0;
|
|
130
|
-
for (const [idx, { result, outputBytes, encodedOutput }] of replacements.entries()) {
|
|
131
|
-
const segmentLength = result.position - srcPos;
|
|
132
|
-
if (segmentLength > 0) {
|
|
133
|
-
newPlaintext.set(plaintext.slice(srcPos, result.position), dstPos);
|
|
134
|
-
dstPos += segmentLength;
|
|
168
|
+
// Copy remaining segment after last replacement
|
|
169
|
+
if (srcPos < plaintext.length) {
|
|
170
|
+
newPlaintext.set(plaintext.slice(srcPos), dstPos);
|
|
135
171
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
newPlaintext.set(outputBytes, dstPos);
|
|
139
|
-
dstPos += outputBytes.length;
|
|
140
|
-
srcPos = result.position + result.length;
|
|
141
|
-
}
|
|
142
|
-
if (srcPos < plaintext.length) {
|
|
143
|
-
newPlaintext.set(plaintext.slice(srcPos), dstPos);
|
|
144
|
-
}
|
|
145
|
-
logger.info(`Replaced ${oprfResults.length} OPRF ranges in plaintext`);
|
|
146
|
-
return newPlaintext;
|
|
172
|
+
logger.info(`Replaced ${oprfResults.length} OPRF ranges in plaintext`);
|
|
173
|
+
return newPlaintext;
|
|
147
174
|
}
|
|
148
|
-
export {
|
|
149
|
-
replaceOprfRanges,
|
|
150
|
-
verifyOprfProofs
|
|
151
|
-
};
|