@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.
Files changed (145) hide show
  1. package/browser/resources/attestor-browser.min.mjs +4512 -0
  2. package/lib/avs/abis/avsDirectoryABI.js +338 -341
  3. package/lib/avs/abis/delegationABI.js +1 -4
  4. package/lib/avs/abis/registryABI.js +719 -722
  5. package/lib/avs/client/create-claim-on-avs.js +129 -157
  6. package/lib/avs/config.js +18 -24
  7. package/lib/avs/contracts/ReclaimServiceManager.js +1 -0
  8. package/lib/avs/contracts/common.js +1 -0
  9. package/lib/avs/contracts/factories/ReclaimServiceManager__factory.js +1139 -1156
  10. package/lib/avs/contracts/factories/index.js +4 -4
  11. package/lib/avs/contracts/index.js +2 -6
  12. package/lib/avs/types/index.js +1 -0
  13. package/lib/avs/utils/contracts.js +30 -50
  14. package/lib/avs/utils/register.js +75 -70
  15. package/lib/avs/utils/tasks.js +38 -45
  16. package/lib/client/create-claim.js +402 -431
  17. package/lib/client/tunnels/make-rpc-tcp-tunnel.js +46 -48
  18. package/lib/client/tunnels/make-rpc-tls-tunnel.js +125 -121
  19. package/lib/client/utils/attestor-pool.js +23 -22
  20. package/lib/client/utils/client-socket.js +86 -109
  21. package/lib/client/utils/message-handler.js +79 -89
  22. package/lib/config/index.js +40 -58
  23. package/lib/external-rpc/benchmark.js +61 -74
  24. package/lib/external-rpc/event-bus.js +12 -15
  25. package/lib/external-rpc/handle-incoming-msg.js +216 -225
  26. package/lib/external-rpc/jsc-polyfills/1.js +70 -68
  27. package/lib/external-rpc/jsc-polyfills/2.js +17 -12
  28. package/lib/external-rpc/jsc-polyfills/event.js +10 -15
  29. package/lib/external-rpc/jsc-polyfills/index.js +2 -2
  30. package/lib/external-rpc/jsc-polyfills/ws.js +77 -79
  31. package/lib/external-rpc/setup-browser.js +28 -28
  32. package/lib/external-rpc/setup-jsc.js +17 -17
  33. package/lib/external-rpc/types.js +1 -0
  34. package/lib/external-rpc/utils.js +89 -89
  35. package/lib/external-rpc/zk.js +55 -50
  36. package/lib/index.js +2 -6
  37. package/lib/mechain/abis/governanceABI.js +457 -460
  38. package/lib/mechain/abis/taskABI.js +502 -505
  39. package/lib/mechain/client/create-claim-on-mechain.js +24 -29
  40. package/lib/mechain/constants/index.js +3 -8
  41. package/lib/mechain/types/index.js +1 -0
  42. package/lib/proto/api.js +4200 -4087
  43. package/lib/proto/tee-bundle.js +1261 -1241
  44. package/lib/providers/http/index.js +616 -603
  45. package/lib/providers/http/patch-parse5-tree.js +27 -29
  46. package/lib/providers/http/utils.js +289 -248
  47. package/lib/providers/index.js +3 -6
  48. package/lib/server/create-server.js +89 -91
  49. package/lib/server/handlers/claimTeeBundle.js +231 -211
  50. package/lib/server/handlers/claimTunnel.js +66 -73
  51. package/lib/server/handlers/completeClaimOnChain.js +20 -25
  52. package/lib/server/handlers/createClaimOnChain.js +21 -27
  53. package/lib/server/handlers/createTaskOnMechain.js +40 -50
  54. package/lib/server/handlers/createTunnel.js +85 -90
  55. package/lib/server/handlers/disconnectTunnel.js +4 -7
  56. package/lib/server/handlers/fetchCertificateBytes.js +37 -53
  57. package/lib/server/handlers/index.js +21 -24
  58. package/lib/server/handlers/init.js +27 -28
  59. package/lib/server/handlers/toprf.js +13 -16
  60. package/lib/server/socket.js +97 -100
  61. package/lib/server/tunnels/make-tcp-tunnel.js +161 -186
  62. package/lib/server/utils/apm.js +32 -25
  63. package/lib/server/utils/assert-valid-claim-request.js +305 -334
  64. package/lib/server/utils/config-env.js +2 -2
  65. package/lib/server/utils/dns.js +12 -18
  66. package/lib/server/utils/gcp-attestation.js +233 -181
  67. package/lib/server/utils/generics.d.ts +1 -1
  68. package/lib/server/utils/generics.js +43 -37
  69. package/lib/server/utils/iso.js +253 -256
  70. package/lib/server/utils/keep-alive.js +36 -36
  71. package/lib/server/utils/nitro-attestation.js +295 -220
  72. package/lib/server/utils/oprf-raw.js +48 -55
  73. package/lib/server/utils/process-handshake.js +200 -218
  74. package/lib/server/utils/proxy-session.js +5 -5
  75. package/lib/server/utils/tee-oprf-mpc-verification.js +82 -78
  76. package/lib/server/utils/tee-oprf-verification.js +165 -142
  77. package/lib/server/utils/tee-transcript-reconstruction.js +176 -129
  78. package/lib/server/utils/tee-verification.js +397 -334
  79. package/lib/server/utils/validation.js +30 -37
  80. package/lib/types/bgp.js +1 -0
  81. package/lib/types/claims.js +1 -0
  82. package/lib/types/client.js +1 -0
  83. package/lib/types/general.js +1 -0
  84. package/lib/types/handlers.js +1 -0
  85. package/lib/types/providers.d.ts +3 -2
  86. package/lib/types/providers.gen.js +9 -15
  87. package/lib/types/providers.js +1 -0
  88. package/lib/types/rpc.js +1 -0
  89. package/lib/types/signatures.d.ts +1 -2
  90. package/lib/types/signatures.js +1 -0
  91. package/lib/types/tunnel.js +1 -0
  92. package/lib/types/zk.js +1 -0
  93. package/lib/utils/auth.js +54 -66
  94. package/lib/utils/b64-json.js +15 -15
  95. package/lib/utils/bgp-listener.js +107 -111
  96. package/lib/utils/claims.js +89 -80
  97. package/lib/utils/env.js +13 -17
  98. package/lib/utils/error.js +43 -47
  99. package/lib/utils/generics.js +284 -235
  100. package/lib/utils/http-parser.js +232 -187
  101. package/lib/utils/logger.js +80 -71
  102. package/lib/utils/prepare-packets.js +69 -67
  103. package/lib/utils/redactions.js +163 -121
  104. package/lib/utils/retries.js +22 -24
  105. package/lib/utils/signatures/eth.js +29 -28
  106. package/lib/utils/signatures/index.js +5 -10
  107. package/lib/utils/socket-base.js +84 -88
  108. package/lib/utils/tls.js +28 -28
  109. package/lib/utils/ws.js +19 -19
  110. package/lib/utils/zk.js +542 -582
  111. package/package.json +12 -5
  112. package/lib/external-rpc/global.d.js +0 -0
  113. package/lib/scripts/build-browser.d.ts +0 -1
  114. package/lib/scripts/build-jsc.d.ts +0 -1
  115. package/lib/scripts/build-lib.d.ts +0 -1
  116. package/lib/scripts/check-avs-registration.d.ts +0 -1
  117. package/lib/scripts/check-avs-registration.js +0 -28
  118. package/lib/scripts/fallbacks/crypto.d.ts +0 -1
  119. package/lib/scripts/fallbacks/crypto.js +0 -4
  120. package/lib/scripts/fallbacks/empty.d.ts +0 -3
  121. package/lib/scripts/fallbacks/empty.js +0 -4
  122. package/lib/scripts/fallbacks/re2.d.ts +0 -1
  123. package/lib/scripts/fallbacks/re2.js +0 -7
  124. package/lib/scripts/fallbacks/snarkjs.d.ts +0 -1
  125. package/lib/scripts/fallbacks/snarkjs.js +0 -10
  126. package/lib/scripts/fallbacks/stwo.d.ts +0 -6
  127. package/lib/scripts/fallbacks/stwo.js +0 -159
  128. package/lib/scripts/generate-provider-types.d.ts +0 -5
  129. package/lib/scripts/generate-provider-types.js +0 -101
  130. package/lib/scripts/generate-receipt.d.ts +0 -9
  131. package/lib/scripts/generate-receipt.js +0 -101
  132. package/lib/scripts/generate-toprf-keys.d.ts +0 -1
  133. package/lib/scripts/generate-toprf-keys.js +0 -24
  134. package/lib/scripts/jsc-cli-rpc.d.ts +0 -1
  135. package/lib/scripts/jsc-cli-rpc.js +0 -35
  136. package/lib/scripts/register-avs-operator.d.ts +0 -1
  137. package/lib/scripts/register-avs-operator.js +0 -3
  138. package/lib/scripts/start-server.d.ts +0 -1
  139. package/lib/scripts/start-server.js +0 -11
  140. package/lib/scripts/update-avs-metadata.d.ts +0 -1
  141. package/lib/scripts/update-avs-metadata.js +0 -20
  142. package/lib/scripts/utils.d.ts +0 -1
  143. package/lib/scripts/utils.js +0 -10
  144. package/lib/scripts/whitelist-operator.d.ts +0 -1
  145. package/lib/scripts/whitelist-operator.js +0 -16
@@ -1,151 +1,174 @@
1
- import bs58 from "bs58";
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
- async function verifyOprfProofs(bundleData, logger) {
5
- if (!bundleData.oprfVerifications || bundleData.oprfVerifications.length === 0) {
6
- logger.debug("No OPRF verifications present in bundle");
7
- return [];
8
- }
9
- const { tOutputPayload } = bundleData;
10
- const consolidatedCiphertext = tOutputPayload.consolidatedResponseCiphertext;
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
- logger.info(`Successfully verified ${results.length} OPRF proofs`);
34
- return results;
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
- const publicSignalsJson = JSON.parse(new TextDecoder().decode(oprfData.publicSignalsJson));
38
- const { proof, publicSignals, cipher } = publicSignalsJson;
39
- if (!proof || !publicSignals) {
40
- throw new Error("Missing proof or public signals in OPRF data");
41
- }
42
- const ciphertextChunk = consolidatedCiphertext.slice(
43
- oprfData.streamPos,
44
- oprfData.streamPos + oprfData.streamLength
45
- );
46
- const completePublicSignals = {
47
- out: publicSignals.out || Uint8Array.from([]),
48
- // Replace null input with extracted ciphertext
49
- in: ciphertextChunk,
50
- // Convert base64 nonces and counters
51
- noncesAndCounters: publicSignals.blocks?.map((block) => ({
52
- nonce: Buffer.from(block.nonce || "", "base64"),
53
- counter: block.counter || 0,
54
- boundary: block.boundary || ""
55
- })) || [],
56
- // Process TOPRF data
57
- toprf: publicSignals.toprf ? {
58
- ...publicSignals.toprf,
59
- // Convert domain separator from base64
60
- domainSeparator: publicSignals.toprf.domainSeparator ? Buffer.from(publicSignals.toprf.domainSeparator, "base64").toString("utf8") : "reclaim",
61
- // Convert output from base64
62
- output: publicSignals.toprf.output ? Buffer.from(publicSignals.toprf.output, "base64") : new Uint8Array(),
63
- // Convert response fields from base64
64
- responses: publicSignals.toprf.responses?.map((resp) => ({
65
- publicKeyShare: Buffer.from(resp.publicKeyShare || "", "base64"),
66
- evaluated: Buffer.from(resp.evaluated || "", "base64"),
67
- c: Buffer.from(resp.c || "", "base64"),
68
- r: Buffer.from(resp.r || "", "base64")
69
- })) || [],
70
- // Locations are already in correct format
71
- locations: publicSignals.toprf.locations || []
72
- } : void 0
73
- };
74
- const algorithm = cipher.replace("-toprf", "");
75
- const zkEngine = "gnark";
76
- const oprfOperator = makeDefaultOPRFOperator(algorithm, zkEngine, logger);
77
- const proofBytes = Buffer.from(proof, "base64");
78
- const isValid = await oprfOperator.groth16Verify(
79
- completePublicSignals,
80
- proofBytes,
81
- logger
82
- );
83
- if (!isValid) {
84
- throw new Error("OPRF proof verification failed");
85
- }
86
- logger.debug(`OPRF ${index}: Proof verified successfully`);
87
- const oprfOutput = completePublicSignals.toprf?.output;
88
- if (!oprfOutput || oprfOutput.length === 0) {
89
- throw new Error("No OPRF output found in verified proof");
90
- }
91
- const oprfLocation = completePublicSignals.toprf?.locations?.[0];
92
- if (!oprfLocation) {
93
- throw new Error("No OPRF location found in public signals");
94
- }
95
- logger.info(`OPRF #${index}: streamPos=${oprfData.streamPos}, locationPos=${oprfLocation.pos}, finalPos=${oprfData.streamPos + oprfLocation.pos}, len=${oprfLocation.len}`);
96
- return {
97
- // The position in the plaintext where to replace (stream position + OPRF location within chunk)
98
- position: oprfData.streamPos + oprfLocation.pos,
99
- length: oprfLocation.len,
100
- output: oprfOutput
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
- function replaceOprfRanges(plaintext, oprfResults, logger) {
104
- if (oprfResults.length === 0) {
105
- return plaintext;
106
- }
107
- const replacements = oprfResults.map((result) => {
108
- let outputBytes;
109
- let encodedOutput;
110
- if (result.isMPC) {
111
- encodedOutput = bs58.encode(result.output);
112
- outputBytes = new TextEncoder().encode(encodedOutput);
113
- } else {
114
- encodedOutput = Buffer.from(result.output).toString("base64");
115
- const truncated = encodedOutput.substring(0, result.length);
116
- outputBytes = new TextEncoder().encode(truncated);
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
- return { result, outputBytes, encodedOutput };
119
- });
120
- replacements.sort((a, b) => a.result.position - b.result.position);
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
- const currentContent = plaintext.slice(result.position, result.position + result.length);
137
- logger.info(`OPRF #${idx} at pos ${result.position}: "${Buffer.from(currentContent).toString("utf8")}" (${result.length}b) -> "${encodedOutput}" (${outputBytes.length}b)${result.isMPC ? " [MPC/base58]" : ""}`);
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
- };