Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<script src="browser-rpc/resources/snarkjs/snarkjs.min.js">
</script>
<script type="module">
// Load s2circuits as ES module and assign to window BEFORE attestor loads
import * as s2circuits from './browser-rpc/resources/stwo/s2circuits.js'
window.s2circuits = s2circuits

import * as ReclaimAttestorCore from './browser-rpc/resources/attestor-browser.min.mjs'
window.ReclaimAttestorCore = ReclaimAttestorCore
ReclaimAttestorCore.setupWindowRpc()
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@peculiar/webcrypto": "^1.5.0",
"@peculiar/x509": "^1.14.0",
"@reclaimprotocol/tls": "github:reclaimprotocol/tls",
"@reclaimprotocol/zk-symmetric-crypto": "^5.0.4",
"@reclaimprotocol/zk-symmetric-crypto": "^5.0.9",
"ajv": "^8.17.1",
"bs58": "^6.0.0",
"canonicalize": "^2.0.0",
Expand Down
15 changes: 15 additions & 0 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum ErrorCode {
enum ZKProofEngine {
ZK_ENGINE_SNARKJS = 0;
ZK_ENGINE_GNARK = 1;
ZK_ENGINE_STWO = 2;
}

message ClaimContext {
Expand Down Expand Up @@ -212,6 +213,20 @@ message MessageReveal {
message MessageRevealZk {
repeated ZKProof proofs = 1;
repeated TOPRFProof toprfs = 2;
/** Markers for server-side OPRF computation (oprf-raw mode) */
repeated OPRFRawMarker oprfRawMarkers = 3;
/**
* If an oprf-raw marker from the previous packet overshot into this packet,
* this indicates how many bytes of plaintext from this packet should be
* collected to complete the server-side OPRF computation.
*/
uint32 overshotOprfRawLength = 4;
}

/** Marker for server-side OPRF computation (oprf-raw mode). */
message OPRFRawMarker {
/** Location of the data to OPRF in the revealed plaintext */
DataSlice dataLocation = 1;
}

message ZKProof {
Expand Down
1 change: 1 addition & 0 deletions provider-schemas/http/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ properties:
enum:
- oprf
- oprf-mpc
- oprf-raw
additionalProperties: false
paramValues:
type: object
Expand Down
9 changes: 4 additions & 5 deletions src/client/create-claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { asciiToUint8Array } from '@reclaimprotocol/tls'
import { makeRpcTlsTunnel } from '#src/client/tunnels/make-rpc-tls-tunnel.ts'
import { getAttestorClientFromPool } from '#src/client/utils/attestor-pool.ts'
import { DEFAULT_HTTPS_PORT, PROVIDER_CTX, TOPRF_DOMAIN_SEPARATOR } from '#src/config/index.ts'
import { ClaimTunnelRequest, ZKProofEngine } from '#src/proto/api.ts'
import { ClaimTunnelRequest } from '#src/proto/api.ts'
import { providers } from '#src/providers/index.ts'
import type {
CreateClaimOnAttestorOpts,
Expand Down Expand Up @@ -304,9 +304,7 @@ async function _createClaimOnAttestor<N extends ProviderName>(
owner: getAddress(),
},
transcript:transcript,
zkEngine: zkEngine === 'gnark'
? ZKProofEngine.ZK_ENGINE_GNARK
: ZKProofEngine.ZK_ENGINE_SNARKJS,
zkEngine: getEngineProto(zkEngine),
fixedServerIV: serverIV!,
fixedClientIV: clientIV!,
})
Expand Down Expand Up @@ -515,12 +513,13 @@ async function _createClaimOnAttestor<N extends ProviderName>(
revealedPackets.push(...packets.filter(p => p.sender === 'server'))
} else {
for(const {
block, redactedPlaintext, overshotToprfFromPrevBlock, toprfs
block, redactedPlaintext, overshotToprfFromPrevBlock, toprfs, oprfRawMarkers
} of serverPacketsToReveal) {
setRevealOfMessage(block.message, {
type: 'zk',
redactedPlaintext,
toprfs,
oprfRawMarkers,
overshotToprfFromPrevBlock
})
Comment thread
Scratch-net marked this conversation as resolved.
revealedPackets.push(
Expand Down
118 changes: 116 additions & 2 deletions src/proto/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/scripts/build-browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ set -e
cp -r node_modules/@reclaimprotocol/zk-symmetric-crypto/resources/ ./browser/resources
cp node_modules/snarkjs/build/snarkjs.min.js ./browser/resources/snarkjs/snarkjs.min.js
# remove r1cs files, we don't need them in prod
rm -r ./browser/resources/snarkjs/*/*.r1cs
rm -rf ./browser/resources/snarkjs/*/*.r1cs 2>/dev/null || true
# remove gnark libs, they are only for nodejs
rm -r ./browser/resources/gnark
rm -rf ./browser/resources/gnark 2>/dev/null || true
# ensure stwo resources exist (s2circuits.js + s2circuits_bg.wasm)
if [ ! -f ./browser/resources/stwo/s2circuits.js ]; then
echo "Warning: stwo/s2circuits.js not found in resources"
fi
if [ ! -f ./browser/resources/stwo/s2circuits_bg.wasm ]; then
echo "Warning: stwo/s2circuits_bg.wasm not found in resources"
fi
npm run run:tsc -- src/scripts/build-browser.ts
npm run run:tsc -- src/scripts/build-jsc.ts
1 change: 1 addition & 0 deletions src/scripts/build-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const rslt = await esbuild.build({
'ip-cidr': '#src/scripts/fallbacks/empty.ts',
'snarkjs': '#src/scripts/fallbacks/snarkjs.ts',
're2': '#src/scripts/fallbacks/re2.ts',
'@reclaimprotocol/zk-symmetric-crypto/stwo': '#src/scripts/fallbacks/stwo.ts',
},
external: [
'dotenv',
Expand Down
1 change: 1 addition & 0 deletions src/scripts/build-jsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const rslt = await esbuild.build({
'ip-cidr': '#src/scripts/fallbacks/empty.ts',
'snarkjs': '#src/scripts/fallbacks/empty.ts',
're2': '#src/scripts/fallbacks/re2.ts',
'@reclaimprotocol/zk-symmetric-crypto/stwo': '#src/scripts/fallbacks/stwo.ts',
},
external: [
'dotenv',
Expand Down
Loading
Loading