@open-e2ee/signal-protocol-sdk 8.2.0 → 9.1.0
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/ADAPTERS.md +15 -31
- package/ARCHITECTURE.md +5 -7
- package/CHANGELOG.md +128 -0
- package/README.md +52 -49
- package/SECURITY.md +2 -2
- package/client/README.md +11 -0
- package/dist/client/client.d.ts +21 -14
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +93 -78
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +10 -17
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/event-hooks.js +27 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-receive-authorization.d.ts +5 -0
- package/dist/client/group-receive-authorization.d.ts.map +1 -0
- package/dist/client/group-receive-authorization.js +32 -0
- package/dist/client/group-receive-authorization.js.map +1 -0
- package/dist/client/group-sender-key-operations.d.ts +15 -0
- package/dist/client/group-sender-key-operations.d.ts.map +1 -0
- package/dist/client/group-sender-key-operations.js +31 -0
- package/dist/client/group-sender-key-operations.js.map +1 -0
- package/dist/client/groups.d.ts +3 -1
- package/dist/client/groups.d.ts.map +1 -1
- package/dist/client/groups.js +5 -2
- package/dist/client/groups.js.map +1 -1
- package/dist/client/hosted-sandbox-identity.d.ts +32 -0
- package/dist/client/hosted-sandbox-identity.d.ts.map +1 -0
- package/dist/client/hosted-sandbox-identity.js +157 -0
- package/dist/client/hosted-sandbox-identity.js.map +1 -0
- package/dist/client/hosted.d.ts +12 -2
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +12 -2
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/relay-subscription.d.ts +2 -0
- package/dist/client/relay-subscription.d.ts.map +1 -1
- package/dist/client/relay-subscription.js +3 -1
- package/dist/client/relay-subscription.js.map +1 -1
- package/dist/client/sender-key-distribution.d.ts.map +1 -1
- package/dist/client/sender-key-distribution.js +4 -1
- package/dist/client/sender-key-distribution.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts +4 -2
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +61 -51
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts +0 -3
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +28 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/pq/kyber.d.ts +1 -1
- package/dist/internal/crypto/pq/kyber.js +1 -1
- package/dist/internal/encoding/proto/sender-key-message.d.ts +2 -2
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.js +5 -2
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -1
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +5 -2
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/wire.d.ts +0 -2
- package/dist/internal/groups/wire.d.ts.map +1 -1
- package/dist/internal/groups/wire.js +0 -6
- package/dist/internal/groups/wire.js.map +1 -1
- package/dist/internal/manager/manager.d.ts.map +1 -1
- package/dist/internal/manager/manager.js +0 -1
- package/dist/internal/manager/manager.js.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts +0 -17
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.js +0 -4
- package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.d.ts +2 -32
- package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.js +4 -85
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.d.ts +2 -2
- package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.js +2 -6
- package/dist/internal/protocol/sealed-sender/index.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +0 -19
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +1 -48
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts +9 -13
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +90 -95
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts +0 -2
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js +4 -12
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/spqr.d.ts +1 -1
- package/dist/internal/protocol/spqr/spqr.js +1 -1
- package/dist/internal/protocol/x3dh/x3dh.d.ts.map +1 -1
- package/dist/internal/protocol/x3dh/x3dh.js +1 -1
- package/dist/internal/protocol/x3dh/x3dh.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.d.ts +3 -54
- package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.js +4 -91
- package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts +3 -64
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/endorsements.js +4 -134
- package/dist/internal/protocol/zk/credentials/endorsements.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/index.d.ts +3 -3
- package/dist/internal/protocol/zk/credentials/index.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/index.js +3 -3
- package/dist/internal/protocol/zk/credentials/index.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/issuance.d.ts +3 -26
- package/dist/internal/protocol/zk/credentials/issuance.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/issuance.js +3 -80
- package/dist/internal/protocol/zk/credentials/issuance.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.d.ts +4 -73
- package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.js +4 -152
- package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -1
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts +1 -61
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/auth-credential.js +2 -196
- package/dist/internal/protocol/zk/groups/auth-credential.js.map +1 -1
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts +1 -86
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js +1 -152
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js.map +1 -1
- package/dist/internal/protocol/zk/groups/index.d.ts +4 -4
- package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/index.js +4 -4
- package/dist/internal/protocol/zk/groups/index.js.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +2 -57
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.js +2 -174
- package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -1
- package/dist/internal/protocol/zk/groups/server-params.d.ts +8 -72
- package/dist/internal/protocol/zk/groups/server-params.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/server-params.js +8 -108
- package/dist/internal/protocol/zk/groups/server-params.js.map +1 -1
- package/dist/internal/protocol/zk/proofs/sign.d.ts +1 -2
- package/dist/internal/protocol/zk/proofs/sign.d.ts.map +1 -1
- package/dist/internal/protocol/zk/proofs/sign.js +2 -11
- package/dist/internal/protocol/zk/proofs/sign.js.map +1 -1
- package/dist/internal/session/ratchet.d.ts.map +1 -1
- package/dist/internal/session/ratchet.js +0 -2
- package/dist/internal/session/ratchet.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +3 -3
- package/dist/local/store/key-value/adapter.d.ts.map +1 -1
- package/dist/local/store/key-value/adapter.js +30 -15
- package/dist/local/store/key-value/adapter.js.map +1 -1
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -1
- package/dist/local/store/key-value/backend-conformance.js +25 -0
- package/dist/local/store/key-value/backend-conformance.js.map +1 -1
- package/dist/local/store/key-value/batch.d.ts +3 -1
- package/dist/local/store/key-value/batch.d.ts.map +1 -1
- package/dist/local/store/key-value/batch.js +9 -1
- package/dist/local/store/key-value/batch.js.map +1 -1
- package/dist/local/store/key-value/storage.d.ts +6 -0
- package/dist/local/store/key-value/storage.d.ts.map +1 -1
- package/dist/local/store/key-value/transactional-backend.d.ts +1 -1
- package/dist/local/store/key-value/transactional-backend.js +1 -1
- package/dist/local/store/memory/adapter.d.ts +3 -3
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +43 -18
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/sqlite/errors.d.ts +6 -0
- package/dist/local/store/sqlite/errors.d.ts.map +1 -1
- package/dist/local/store/sqlite/errors.js +6 -6
- package/dist/local/store/sqlite/errors.js.map +1 -1
- package/dist/local/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/local/store/sqlite/migrations.js +18 -0
- package/dist/local/store/sqlite/migrations.js.map +1 -1
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +3 -3
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -1
- package/dist/local/store/sqlite/models/skipped-sender-key.js +13 -17
- package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts +3 -3
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +17 -9
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +3 -3
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +59 -20
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/profile/contact-state.d.ts +0 -3
- package/dist/profile/contact-state.d.ts.map +1 -1
- package/dist/profile/contact-state.js +1 -32
- package/dist/profile/contact-state.js.map +1 -1
- package/dist/profile/index.d.ts +2 -1
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +2 -1
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/unidentified-access.d.ts +12 -0
- package/dist/profile/unidentified-access.d.ts.map +1 -0
- package/dist/profile/unidentified-access.js +42 -0
- package/dist/profile/unidentified-access.js.map +1 -0
- package/dist/remote/relay/index.d.ts +4 -7
- package/dist/remote/relay/index.d.ts.map +1 -1
- package/dist/remote/relay/index.js +5 -7
- package/dist/remote/relay/index.js.map +1 -1
- package/dist/remote/relay/types.d.ts +3 -3
- package/dist/types/api.d.ts +29 -8
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +6 -6
- package/dist/types/errors.js.map +1 -1
- package/dist/versions.d.ts +3 -3
- package/dist/versions.js +3 -3
- package/dist/zk/credentials.d.ts +2 -2
- package/dist/zk/credentials.js +2 -2
- package/dist/zk/groups.d.ts +3 -3
- package/dist/zk/groups.d.ts.map +1 -1
- package/dist/zk/groups.js +3 -3
- package/dist/zk/groups.js.map +1 -1
- package/docs/ASSURANCE.md +12 -14
- package/docs/CLIENT_COMPOSITION.md +11 -3
- package/docs/DEVIATIONS.md +24 -25
- package/docs/GETTING_STARTED.md +61 -323
- package/docs/INTERFACES.md +7 -7
- package/docs/PACKAGE_SURFACE.md +14 -16
- package/docs/RECIPES.md +7 -112
- package/groups/README.md +9 -1
- package/local/store/README.md +26 -6
- package/package.json +2 -31
- package/remote/README.md +14 -78
- package/remote/object-store/convex-r2/README.md +17 -49
- package/remote/relay/README.md +24 -18
- package/zk/README.md +6 -7
- package/dist/client/dual-store.d.ts +0 -70
- package/dist/client/dual-store.d.ts.map +0 -1
- package/dist/client/dual-store.js +0 -123
- package/dist/client/dual-store.js.map +0 -1
- package/dist/client/multi-device.d.ts +0 -74
- package/dist/client/multi-device.d.ts.map +0 -1
- package/dist/client/multi-device.js +0 -105
- package/dist/client/multi-device.js.map +0 -1
- package/dist/groups/server.d.ts +0 -10
- package/dist/groups/server.d.ts.map +0 -1
- package/dist/groups/server.js +0 -6
- package/dist/groups/server.js.map +0 -1
- package/dist/internal/encoding/index.d.ts +0 -2
- package/dist/internal/encoding/index.d.ts.map +0 -1
- package/dist/internal/encoding/index.js +0 -2
- package/dist/internal/encoding/index.js.map +0 -1
- package/dist/internal/groups/server-engine.d.ts +0 -118
- package/dist/internal/groups/server-engine.d.ts.map +0 -1
- package/dist/internal/groups/server-engine.js +0 -1268
- package/dist/internal/groups/server-engine.js.map +0 -1
- package/dist/internal/protocol/index.d.ts +0 -24
- package/dist/internal/protocol/index.d.ts.map +0 -1
- package/dist/internal/protocol/index.js +0 -9
- package/dist/internal/protocol/index.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts +0 -56
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/trust-root.js +0 -90
- package/dist/internal/protocol/sealed-sender/trust-root.js.map +0 -1
- package/dist/internal/protocol/triple-ratchet/index.d.ts +0 -21
- package/dist/internal/protocol/triple-ratchet/index.d.ts.map +0 -1
- package/dist/internal/protocol/triple-ratchet/index.js +0 -19
- package/dist/internal/protocol/triple-ratchet/index.js.map +0 -1
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts +0 -233
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts.map +0 -1
- package/dist/internal/protocol/triple-ratchet/ratchet.js +0 -254
- package/dist/internal/protocol/triple-ratchet/ratchet.js.map +0 -1
- package/dist/internal/protocol/zk/proofs/index.d.ts +0 -13
- package/dist/internal/protocol/zk/proofs/index.d.ts.map +0 -1
- package/dist/internal/protocol/zk/proofs/index.js +0 -7
- package/dist/internal/protocol/zk/proofs/index.js.map +0 -1
- package/dist/local/store/sqlite/index.d.ts +0 -20
- package/dist/local/store/sqlite/index.d.ts.map +0 -1
- package/dist/local/store/sqlite/index.js +0 -18
- package/dist/local/store/sqlite/index.js.map +0 -1
- package/dist/remote/object-store/convex-r2/server/index.d.ts +0 -2
- package/dist/remote/object-store/convex-r2/server/index.d.ts.map +0 -1
- package/dist/remote/object-store/convex-r2/server/index.js +0 -2
- package/dist/remote/object-store/convex-r2/server/index.js.map +0 -1
- package/dist/remote/object-store/convex-r2/server.d.ts +0 -129
- package/dist/remote/object-store/convex-r2/server.d.ts.map +0 -1
- package/dist/remote/object-store/convex-r2/server.js +0 -244
- package/dist/remote/object-store/convex-r2/server.js.map +0 -1
- package/dist/remote/relay/memory/adapter.d.ts +0 -252
- package/dist/remote/relay/memory/adapter.d.ts.map +0 -1
- package/dist/remote/relay/memory/adapter.js +0 -1057
- package/dist/remote/relay/memory/adapter.js.map +0 -1
- package/dist/remote/relay/memory/failures.d.ts +0 -58
- package/dist/remote/relay/memory/failures.d.ts.map +0 -1
- package/dist/remote/relay/memory/failures.js +0 -124
- package/dist/remote/relay/memory/failures.js.map +0 -1
- package/dist/remote/relay/memory/group-server.d.ts +0 -13
- package/dist/remote/relay/memory/group-server.d.ts.map +0 -1
- package/dist/remote/relay/memory/group-server.js +0 -19
- package/dist/remote/relay/memory/group-server.js.map +0 -1
- package/dist/remote/relay/memory/index.d.ts +0 -11
- package/dist/remote/relay/memory/index.d.ts.map +0 -1
- package/dist/remote/relay/memory/index.js +0 -7
- package/dist/remote/relay/memory/index.js.map +0 -1
- package/examples/browser/README.md +0 -35
- package/examples/browser/index.html +0 -27
- package/examples/browser/src/exchange.ts +0 -69
- package/examples/browser/src/main.ts +0 -63
- package/examples/browser/src/style.css +0 -9
- package/examples/browser/src/worker.ts +0 -10
- package/examples/browser/vite.config.ts +0 -9
- package/remote/relay/memory/README.md +0 -72
- package/scripts/oe-groups.mjs +0 -166
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* | SPQR | ML-KEM-768 | 3 (192-bit)| Continuous ratchet |
|
|
19
19
|
*
|
|
20
20
|
* **Rationale for ML-KEM-768 in SPQR:**
|
|
21
|
-
* -
|
|
21
|
+
* - Braid spreads each key exchange across multiple messages
|
|
22
22
|
* - ML-KEM-768: 1,088 bytes/ratchet vs ML-KEM-1024: 1,568 bytes
|
|
23
23
|
* - Hybrid mode (EC + PQ) provides defense-in-depth anyway
|
|
24
24
|
* - NIST recommends Level 3 for general-purpose use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x3dh.d.ts","sourceRoot":"","sources":["../../../../internal/protocol/x3dh/x3dh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA+B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"x3dh.d.ts","sourceRoot":"","sources":["../../../../internal/protocol/x3dh/x3dh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA+B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAI3E,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,YAAY,EACZ,SAAS,E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,CAAC;CAC5B;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,aAAa,EAAE,eAAe,EAC9B,WAAW,EAAE,YAAY,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,QAAQ,CAAC,MAAM,CAA+B,GACrD,OAAO,CAAC,UAAU,CAAC,CA6IrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,eAAe,EAC9B,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,GAAG,IAAI,EACvC,KAAK,EAAE,kBAAkB,EACzB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,QAAQ,CAAC,MAAM,CAA+B,GACrD,OAAO,CAAC,mBAAmB,CAAC,CA6F9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,UAAU,GAAG,SAAS,EAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CAcrB"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @see https://signal.org/docs/specifications/x3dh/
|
|
14
14
|
*/
|
|
15
15
|
import { defaultSignalProtocolLogger } from '../../../logger.js';
|
|
16
|
-
import { generateECDHKeyPair, computeSharedSecret, concatBytes, stringToBytes, hkdf, secureZeroBytes, validateX25519PublicKey
|
|
16
|
+
import { generateECDHKeyPair, computeSharedSecret, concatBytes, stringToBytes, hkdf, secureZeroBytes, validateX25519PublicKey } from '../../crypto/index.js';
|
|
17
17
|
import { PREKEY_ALGORITHM_X25519, verifyPreKeySignature } from '../../../keys/prekey-signature.js';
|
|
18
18
|
// ============================================================================
|
|
19
19
|
// FUNCTIONS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x3dh.js","sourceRoot":"","sources":["../../../../internal/protocol/x3dh/x3dh.ts"],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C;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,GAAe,EACf,GAAe,EACf,GAAe,EACf,GAA2B,EAC3B,UAAkB;IAElB,6BAA6B;IAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,iEAAiE;IACjE,qFAAqF;IACrF,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAEzC,mCAAmC;IACnC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB;IACrD,MAAM,IAAI,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAEvC,OAAO,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ZK
|
|
2
|
+
* ZK credential parameters and representations
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
* Provides:
|
|
6
6
|
* - SystemParams: deterministic system-wide generator points
|
|
7
|
-
* -
|
|
7
|
+
* - CredentialPublicKey: the issuer's public credential key
|
|
8
8
|
* - Credential: the issued (t, U, V) triple
|
|
9
9
|
*
|
|
10
10
|
* @see https://signal.org/docs/
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import { RistrettoPoint } from '../proofs/sho.js';
|
|
13
13
|
export {};
|
|
14
14
|
/** Maximum number of hidden attributes a credential can carry. */
|
|
15
15
|
export declare const NUM_SUPPORTED_ATTRS = 7;
|
|
@@ -48,33 +48,6 @@ export interface Credential {
|
|
|
48
48
|
U: RistrettoPoint;
|
|
49
49
|
V: RistrettoPoint;
|
|
50
50
|
}
|
|
51
|
-
export interface CredentialPrivateKey {
|
|
52
|
-
w: bigint;
|
|
53
|
-
wprime: bigint;
|
|
54
|
-
W: RistrettoPoint;
|
|
55
|
-
x0: bigint;
|
|
56
|
-
x1: bigint;
|
|
57
|
-
y: bigint[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Derive a credential private key deterministically from randomness.
|
|
61
|
-
*
|
|
62
|
-
* Uses ShoHmacSha256 keyed with a fixed label, absorbing the provided
|
|
63
|
-
* randomness, then deriving each scalar via `sho.getScalar()`.
|
|
64
|
-
*/
|
|
65
|
-
export declare function generatePrivateKey(randomness: Uint8Array): CredentialPrivateKey;
|
|
66
|
-
/**
|
|
67
|
-
* Issue a credential over a vector of attribute points M.
|
|
68
|
-
*
|
|
69
|
-
* Computes:
|
|
70
|
-
* t = sho.getScalar()
|
|
71
|
-
* U = sho.getPoint()
|
|
72
|
-
* V = W + (x0 + x1*t)*U + sum(y[i]*M[i])
|
|
73
|
-
*
|
|
74
|
-
* The caller must supply a ShoHmacSha256 that has already absorbed any
|
|
75
|
-
* context binding data (e.g. the public key, attribute commitments).
|
|
76
|
-
*/
|
|
77
|
-
export declare function credentialCore(key: CredentialPrivateKey, M: RistrettoPoint[], sho: ShoHmacSha256): Credential;
|
|
78
51
|
export interface CredentialPublicKey {
|
|
79
52
|
/**
|
|
80
53
|
* Commitment to W: C_W = W + wprime * G_wprime
|
|
@@ -87,35 +60,11 @@ export interface CredentialPublicKey {
|
|
|
87
60
|
*/
|
|
88
61
|
I: RistrettoPoint[];
|
|
89
62
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Derive the public key from a private key.
|
|
92
|
-
*
|
|
93
|
-
* C_W = W + wprime * G_wprime
|
|
94
|
-
*
|
|
95
|
-
* I is computed iteratively for attributes 1 through NUM_SUPPORTED_ATTRS - 1:
|
|
96
|
-
* accum = G_V - x0*G_x0 - x1*G_x1 - y[0]*G_y[0]
|
|
97
|
-
* for n = 1 .. NUM_SUPPORTED_ATTRS-1:
|
|
98
|
-
* accum -= y[n]*G_y[n]
|
|
99
|
-
* I.push(accum)
|
|
100
|
-
*
|
|
101
|
-
* I has length NUM_SUPPORTED_ATTRS - 1 = 6.
|
|
102
|
-
* I[0] includes subtraction through y[1] (numAttrs=2).
|
|
103
|
-
* getI(numAttrs) returns I[numAttrs - 2].
|
|
104
|
-
*/
|
|
105
|
-
export declare function derivePublicKey(priv: CredentialPrivateKey): CredentialPublicKey;
|
|
106
63
|
/**
|
|
107
64
|
* Retrieve the public key image for a credential with `numAttrs` attributes.
|
|
108
65
|
* numAttrs must be in [2, NUM_SUPPORTED_ATTRS].
|
|
109
66
|
*/
|
|
110
67
|
export declare function getPublicKeyI(pub: CredentialPublicKey, numAttrs: number): RistrettoPoint;
|
|
111
|
-
export interface CredentialKeyPair {
|
|
112
|
-
privateKey: CredentialPrivateKey;
|
|
113
|
-
publicKey: CredentialPublicKey;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Generate a full credential key pair from randomness.
|
|
117
|
-
*/
|
|
118
|
-
export declare function generateKeyPair(randomness: Uint8Array): CredentialKeyPair;
|
|
119
68
|
/**
|
|
120
69
|
* Serialize a CredentialPublicKey to bytes.
|
|
121
70
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../../internal/protocol/zk/credentials/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../../internal/protocol/zk/credentials/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,OAAO,EAAE,CAAC;AAOV,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,iEAAiE;AACjE,eAAO,MAAM,cAAc,KAAK,CAAC;AAMjC;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,cAAc,EAAE,CAAC;CACvB;AAMD;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,YAAY,CA2B9C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAiBpE;AAMD,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,cAAc,CAAC;IAClB,CAAC,EAAE,cAAc,CAAC;CACnB;AAMD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,EAAE,cAAc,CAAC;IAEpB;;;;OAIG;IACH,CAAC,EAAE,cAAc,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAOxF;AAMD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,mBAAmB,GAAG,UAAU,CAUjF;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,CAWrF"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ZK
|
|
2
|
+
* ZK credential parameters and representations
|
|
3
3
|
*
|
|
4
4
|
*
|
|
5
5
|
* Provides:
|
|
6
6
|
* - SystemParams: deterministic system-wide generator points
|
|
7
|
-
* -
|
|
7
|
+
* - CredentialPublicKey: the issuer's public credential key
|
|
8
8
|
* - Credential: the issued (t, U, V) triple
|
|
9
9
|
*
|
|
10
10
|
* @see https://signal.org/docs/
|
|
11
11
|
*/
|
|
12
12
|
import { ShoSha256 } from '../proofs/sho-sha256.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { RistrettoPoint } from '../proofs/sho.js';
|
|
14
|
+
import { withGeneratorTable } from '../proofs/point-multiplication.js';
|
|
15
15
|
const Point = RistrettoPoint;
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// Constants
|
|
@@ -20,8 +20,6 @@ const Point = RistrettoPoint;
|
|
|
20
20
|
export const NUM_SUPPORTED_ATTRS = 7;
|
|
21
21
|
/** Length in bytes of randomness required for key generation. */
|
|
22
22
|
export const RANDOMNESS_LEN = 32;
|
|
23
|
-
// Scalar field helper -- mod-L arithmetic on bigints.
|
|
24
|
-
const Fn = RistrettoPoint.Fn;
|
|
25
23
|
// Lazy singleton ---------------------------------------------------------
|
|
26
24
|
let _systemParams;
|
|
27
25
|
/**
|
|
@@ -74,83 +72,6 @@ export function systemParamsToBytes(params) {
|
|
|
74
72
|
}
|
|
75
73
|
return out;
|
|
76
74
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Derive a credential private key deterministically from randomness.
|
|
79
|
-
*
|
|
80
|
-
* Uses ShoHmacSha256 keyed with a fixed label, absorbing the provided
|
|
81
|
-
* randomness, then deriving each scalar via `sho.getScalar()`.
|
|
82
|
-
*/
|
|
83
|
-
export function generatePrivateKey(randomness) {
|
|
84
|
-
if (randomness.length < RANDOMNESS_LEN) {
|
|
85
|
-
throw new Error(`CredentialPrivateKey.generate: need at least ${RANDOMNESS_LEN} bytes of randomness, got ${randomness.length}`);
|
|
86
|
-
}
|
|
87
|
-
const sys = getSystemParams();
|
|
88
|
-
const label = new TextEncoder().encode('Signal_ZKCredential_CredentialPrivateKey_generate_20230410');
|
|
89
|
-
const sho = new ShoHmacSha256(label);
|
|
90
|
-
sho.absorbAndRatchet(randomness);
|
|
91
|
-
const w = sho.getScalar();
|
|
92
|
-
const W = multiscalarMultiply([w], [sys.G_w]);
|
|
93
|
-
const wprime = sho.getScalar();
|
|
94
|
-
const x0 = sho.getScalar();
|
|
95
|
-
const x1 = sho.getScalar();
|
|
96
|
-
const y = [];
|
|
97
|
-
for (let i = 0; i < NUM_SUPPORTED_ATTRS; i++) {
|
|
98
|
-
y.push(sho.getScalar());
|
|
99
|
-
}
|
|
100
|
-
return { w, wprime, W, x0, x1, y };
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Issue a credential over a vector of attribute points M.
|
|
104
|
-
*
|
|
105
|
-
* Computes:
|
|
106
|
-
* t = sho.getScalar()
|
|
107
|
-
* U = sho.getPoint()
|
|
108
|
-
* V = W + (x0 + x1*t)*U + sum(y[i]*M[i])
|
|
109
|
-
*
|
|
110
|
-
* The caller must supply a ShoHmacSha256 that has already absorbed any
|
|
111
|
-
* context binding data (e.g. the public key, attribute commitments).
|
|
112
|
-
*/
|
|
113
|
-
export function credentialCore(key, M, sho) {
|
|
114
|
-
if (M.length > NUM_SUPPORTED_ATTRS) {
|
|
115
|
-
throw new Error(`credentialCore: too many attributes (${M.length} > ${NUM_SUPPORTED_ATTRS})`);
|
|
116
|
-
}
|
|
117
|
-
const t = sho.getScalar();
|
|
118
|
-
const U = sho.getPoint();
|
|
119
|
-
// V = W + (x0 + x1*t) * U + sum(y[i] * M[i])
|
|
120
|
-
const x0_plus_x1t = Fn.create(key.x0 + Fn.create(key.x1 * t));
|
|
121
|
-
let V = key.W.add(U.multiply(x0_plus_x1t));
|
|
122
|
-
for (let i = 0; i < M.length; i++) {
|
|
123
|
-
V = V.add(M[i].multiply(key.y[i]));
|
|
124
|
-
}
|
|
125
|
-
return { t, U, V };
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Derive the public key from a private key.
|
|
129
|
-
*
|
|
130
|
-
* C_W = W + wprime * G_wprime
|
|
131
|
-
*
|
|
132
|
-
* I is computed iteratively for attributes 1 through NUM_SUPPORTED_ATTRS - 1:
|
|
133
|
-
* accum = G_V - x0*G_x0 - x1*G_x1 - y[0]*G_y[0]
|
|
134
|
-
* for n = 1 .. NUM_SUPPORTED_ATTRS-1:
|
|
135
|
-
* accum -= y[n]*G_y[n]
|
|
136
|
-
* I.push(accum)
|
|
137
|
-
*
|
|
138
|
-
* I has length NUM_SUPPORTED_ATTRS - 1 = 6.
|
|
139
|
-
* I[0] includes subtraction through y[1] (numAttrs=2).
|
|
140
|
-
* getI(numAttrs) returns I[numAttrs - 2].
|
|
141
|
-
*/
|
|
142
|
-
export function derivePublicKey(priv) {
|
|
143
|
-
const sys = getSystemParams();
|
|
144
|
-
const C_W = priv.W.add(multiscalarMultiply([priv.wprime], [sys.G_wprime]));
|
|
145
|
-
// Start: G_V - x0*G_x0 - x1*G_x1 - y[0]*G_y[0]
|
|
146
|
-
let accum = sys.G_V.subtract(multiscalarMultiply([priv.x0, priv.x1, priv.y[0]], [sys.G_x0, sys.G_x1, sys.G_y[0]]));
|
|
147
|
-
const I = [];
|
|
148
|
-
for (let n = 1; n < NUM_SUPPORTED_ATTRS; n++) {
|
|
149
|
-
accum = accum.subtract(multiscalarMultiply([priv.y[n]], [sys.G_y[n]]));
|
|
150
|
-
I.push(accum);
|
|
151
|
-
}
|
|
152
|
-
return { C_W, I };
|
|
153
|
-
}
|
|
154
75
|
/**
|
|
155
76
|
* Retrieve the public key image for a credential with `numAttrs` attributes.
|
|
156
77
|
* numAttrs must be in [2, NUM_SUPPORTED_ATTRS].
|
|
@@ -161,14 +82,6 @@ export function getPublicKeyI(pub, numAttrs) {
|
|
|
161
82
|
}
|
|
162
83
|
return pub.I[numAttrs - 2];
|
|
163
84
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Generate a full credential key pair from randomness.
|
|
166
|
-
*/
|
|
167
|
-
export function generateKeyPair(randomness) {
|
|
168
|
-
const privateKey = generatePrivateKey(randomness);
|
|
169
|
-
const publicKey = derivePublicKey(privateKey);
|
|
170
|
-
return { privateKey, publicKey };
|
|
171
|
-
}
|
|
172
85
|
// ---------------------------------------------------------------------------
|
|
173
86
|
// CredentialPublicKey serialization
|
|
174
87
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../../../internal/protocol/zk/credentials/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../../../internal/protocol/zk/credentials/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,MAAM,KAAK,GAAG,cAAc,CAAC;AAE7B,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAsBjC,2EAA2E;AAE3E,IAAI,aAAuC,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CACpC,4DAA4D,CAC7D,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,GAAG,CAAC,QAA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AAI,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAmB,CAAC;IACrE,MAAM,CAAC,GAAqB,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,CAAC,CAAmB,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -24,38 +24,7 @@
|
|
|
24
24
|
import { ShoHmacSha256, RistrettoPoint } from '../proofs/sho.js';
|
|
25
25
|
export {};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* Endorsements are not issued directly with this key. Instead, the server
|
|
30
|
-
* derives a {@link ServerDerivedKeyPair} for domain separation, rotation,
|
|
31
|
-
* and additional authenticated info.
|
|
32
|
-
*/
|
|
33
|
-
export declare class ServerRootKeyPair {
|
|
34
|
-
readonly sk: bigint;
|
|
35
|
-
readonly public: ServerRootPublicKey;
|
|
36
|
-
private constructor();
|
|
37
|
-
/**
|
|
38
|
-
* Derives a root key by hashing `randomness`.
|
|
39
|
-
*/
|
|
40
|
-
static generate(randomness: Uint8Array): ServerRootKeyPair;
|
|
41
|
-
/**
|
|
42
|
-
* Construct from an existing secret scalar.
|
|
43
|
-
*/
|
|
44
|
-
static fromRaw(sk: bigint): ServerRootKeyPair;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the corresponding public key.
|
|
47
|
-
*/
|
|
48
|
-
publicKey(): ServerRootPublicKey;
|
|
49
|
-
/**
|
|
50
|
-
* Derives a specific key for issuing endorsements.
|
|
51
|
-
*
|
|
52
|
-
* The `tagInfoSho` should have already absorbed domain separation and
|
|
53
|
-
* any "public attributes" specific to the endorsements it issues.
|
|
54
|
-
*/
|
|
55
|
-
deriveKey(tagInfoSho: ShoHmacSha256): ServerDerivedKeyPair;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The public counterpart of {@link ServerRootKeyPair}.
|
|
27
|
+
* The server's public root key for endorsements.
|
|
59
28
|
*
|
|
60
29
|
* Verify issuance with a {@link ServerDerivedPublicKey}.
|
|
61
30
|
*/
|
|
@@ -69,30 +38,12 @@ export declare class ServerRootPublicKey {
|
|
|
69
38
|
/**
|
|
70
39
|
* Derives a specific public key for endorsement verification.
|
|
71
40
|
*
|
|
72
|
-
* The `tagInfoSho` must match
|
|
73
|
-
* {@link ServerRootKeyPair.deriveKey}.
|
|
41
|
+
* The `tagInfoSho` must match the server's input for key derivation.
|
|
74
42
|
*/
|
|
75
43
|
deriveKey(tagInfoSho: ShoHmacSha256): ServerDerivedPublicKey;
|
|
76
44
|
}
|
|
77
45
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* Derived from a {@link ServerRootKeyPair} via
|
|
81
|
-
* {@link ServerRootKeyPair.deriveKey}.
|
|
82
|
-
*/
|
|
83
|
-
export declare class ServerDerivedKeyPair {
|
|
84
|
-
readonly skPrime: bigint;
|
|
85
|
-
readonly public: ServerDerivedPublicKey;
|
|
86
|
-
constructor(skPrime: bigint, pub: ServerDerivedPublicKey);
|
|
87
|
-
/**
|
|
88
|
-
* Verifies that a token is valid for `point` according to this key.
|
|
89
|
-
*
|
|
90
|
-
* Throws {@link VerificationFailure} on mismatch.
|
|
91
|
-
*/
|
|
92
|
-
verify(point: RistrettoPoint, token: Uint8Array): void;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* The public counterpart of {@link ServerDerivedKeyPair}.
|
|
46
|
+
* The server's public key for one endorsement context.
|
|
96
47
|
*
|
|
97
48
|
* Derived from a {@link ServerRootPublicKey}.
|
|
98
49
|
*/
|
|
@@ -131,14 +82,6 @@ export declare class EndorsementResponse {
|
|
|
131
82
|
/** The Schnorr batch proof bytes. */
|
|
132
83
|
readonly proof: Uint8Array;
|
|
133
84
|
constructor(R: Uint8Array[], proof: Uint8Array);
|
|
134
|
-
/**
|
|
135
|
-
* Issues an endorsement for every point in `hiddenAttributePoints`,
|
|
136
|
-
* along with a batch proof of validity.
|
|
137
|
-
*
|
|
138
|
-
* The order of the points matters. The endorsements eventually received
|
|
139
|
-
* by the client will be in the same order.
|
|
140
|
-
*/
|
|
141
|
-
static issue(hiddenAttributePoints: RistrettoPoint[], privateKey: ServerDerivedKeyPair, randomness: Uint8Array): EndorsementResponse;
|
|
142
85
|
/**
|
|
143
86
|
* Validates and retrieves the endorsements stored in this response.
|
|
144
87
|
*
|
|
@@ -149,10 +92,6 @@ export declare class EndorsementResponse {
|
|
|
149
92
|
* if the number of points does not match the number of endorsements.
|
|
150
93
|
*/
|
|
151
94
|
receive(hiddenAttributePoints: RistrettoPoint[], serverPublicKey: ServerDerivedPublicKey): ReceivedEndorsements;
|
|
152
|
-
/**
|
|
153
|
-
* Serialize to bytes: [count(u32 LE)] [R_0..R_n (32 each)] [proof]
|
|
154
|
-
*/
|
|
155
|
-
toBytes(): Uint8Array;
|
|
156
95
|
/**
|
|
157
96
|
* Deserialize from bytes.
|
|
158
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endorsements.d.ts","sourceRoot":"","sources":["../../../../../internal/protocol/zk/credentials/endorsements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,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oB,CA2CtB;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,CAgBvD;CACF;AAMD;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC;IAEvB,YAAY,CAAC,EAAE,UAAU,EAExB;IAED;;;OAGG;IACH,UAAU,IAAI,WAAW,CAMxB;CACF;AAED;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAC;IAE3B,YAAY,CAAC,EAAE,cAAc,EAE5B;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,WAAW,CAMvD;IAED;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAE3C;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAEtC;IAED;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,mBAAmB,GAAG,UAAU,CAGlD;IAED;;OAEG;IACH,QAAQ,IAAI,qBAAqB,CAEhC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI,WAAW,CAE7B;CACF;AAMD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,wEAAwE;IACxE,UAAU,EAAE,qBAAqB,EAAE,CAAC;CACrC"}
|
|
@@ -24,10 +24,8 @@
|
|
|
24
24
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
25
25
|
import { ShoHmacSha256, RistrettoPoint } from '../proofs/sho.js';
|
|
26
26
|
import { Statement } from '../proofs/statement.js';
|
|
27
|
-
import {
|
|
28
|
-
import { RANDOMNESS_LEN } from './credentials.js';
|
|
27
|
+
import { PointArgs } from '../proofs/args.js';
|
|
29
28
|
import { VerificationFailure } from './issuance.js';
|
|
30
|
-
import { constantTimeEqual } from '../../../crypto/utils.js';
|
|
31
29
|
const Point = RistrettoPoint;
|
|
32
30
|
const Fn = Point.Fn;
|
|
33
31
|
const enc = new TextEncoder();
|
|
@@ -39,63 +37,10 @@ const TOKEN_LEN = 16;
|
|
|
39
37
|
/** Small scalar size for batch proof weights (< 2^127 for faster multiply). */
|
|
40
38
|
const SMALL_SCALAR_BYTES = 16;
|
|
41
39
|
// ---------------------------------------------------------------------------
|
|
42
|
-
// ServerRootKeyPair
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
/**
|
|
45
|
-
* A server's root secret key for issuing and verifying endorsements.
|
|
46
|
-
*
|
|
47
|
-
* Endorsements are not issued directly with this key. Instead, the server
|
|
48
|
-
* derives a {@link ServerDerivedKeyPair} for domain separation, rotation,
|
|
49
|
-
* and additional authenticated info.
|
|
50
|
-
*/
|
|
51
|
-
export class ServerRootKeyPair {
|
|
52
|
-
sk;
|
|
53
|
-
public;
|
|
54
|
-
constructor(sk) {
|
|
55
|
-
this.sk = sk;
|
|
56
|
-
this.public = new ServerRootPublicKey(Point.BASE.multiply(sk));
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Derives a root key by hashing `randomness`.
|
|
60
|
-
*/
|
|
61
|
-
static generate(randomness) {
|
|
62
|
-
if (randomness.length < RANDOMNESS_LEN) {
|
|
63
|
-
throw new Error(`ServerRootKeyPair.generate: need ${RANDOMNESS_LEN} bytes of randomness`);
|
|
64
|
-
}
|
|
65
|
-
const sho = new ShoHmacSha256(enc.encode('Signal_ZKCredential_Endorsements_ServerRootKeyPair_generate_20240207'));
|
|
66
|
-
sho.absorbAndRatchet(randomness);
|
|
67
|
-
return new ServerRootKeyPair(sho.getScalar());
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Construct from an existing secret scalar.
|
|
71
|
-
*/
|
|
72
|
-
static fromRaw(sk) {
|
|
73
|
-
return new ServerRootKeyPair(sk);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns the corresponding public key.
|
|
77
|
-
*/
|
|
78
|
-
publicKey() {
|
|
79
|
-
return this.public;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Derives a specific key for issuing endorsements.
|
|
83
|
-
*
|
|
84
|
-
* The `tagInfoSho` should have already absorbed domain separation and
|
|
85
|
-
* any "public attributes" specific to the endorsements it issues.
|
|
86
|
-
*/
|
|
87
|
-
deriveKey(tagInfoSho) {
|
|
88
|
-
const t = tagInfoSho.getScalar();
|
|
89
|
-
const skPrime = Fn.inv(Fn.create(this.sk + t));
|
|
90
|
-
const publicKey = this.public.deriveKeyFromTagScalar(t);
|
|
91
|
-
return new ServerDerivedKeyPair(skPrime, publicKey);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// ---------------------------------------------------------------------------
|
|
95
40
|
// ServerRootPublicKey
|
|
96
41
|
// ---------------------------------------------------------------------------
|
|
97
42
|
/**
|
|
98
|
-
* The public
|
|
43
|
+
* The server's public root key for endorsements.
|
|
99
44
|
*
|
|
100
45
|
* Verify issuance with a {@link ServerDerivedPublicKey}.
|
|
101
46
|
*/
|
|
@@ -113,8 +58,7 @@ export class ServerRootPublicKey {
|
|
|
113
58
|
/**
|
|
114
59
|
* Derives a specific public key for endorsement verification.
|
|
115
60
|
*
|
|
116
|
-
* The `tagInfoSho` must match
|
|
117
|
-
* {@link ServerRootKeyPair.deriveKey}.
|
|
61
|
+
* The `tagInfoSho` must match the server's input for key derivation.
|
|
118
62
|
*/
|
|
119
63
|
deriveKey(tagInfoSho) {
|
|
120
64
|
const t = tagInfoSho.getScalar();
|
|
@@ -127,39 +71,10 @@ export class ServerRootPublicKey {
|
|
|
127
71
|
}
|
|
128
72
|
}
|
|
129
73
|
// ---------------------------------------------------------------------------
|
|
130
|
-
// ServerDerivedKeyPair
|
|
131
|
-
// ---------------------------------------------------------------------------
|
|
132
|
-
/**
|
|
133
|
-
* A specific secret key pair for issuing and verifying endorsements.
|
|
134
|
-
*
|
|
135
|
-
* Derived from a {@link ServerRootKeyPair} via
|
|
136
|
-
* {@link ServerRootKeyPair.deriveKey}.
|
|
137
|
-
*/
|
|
138
|
-
export class ServerDerivedKeyPair {
|
|
139
|
-
skPrime;
|
|
140
|
-
public;
|
|
141
|
-
constructor(skPrime, pub) {
|
|
142
|
-
this.skPrime = skPrime;
|
|
143
|
-
this.public = pub;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Verifies that a token is valid for `point` according to this key.
|
|
147
|
-
*
|
|
148
|
-
* Throws {@link VerificationFailure} on mismatch.
|
|
149
|
-
*/
|
|
150
|
-
verify(point, token) {
|
|
151
|
-
const P = point.multiply(this.skPrime);
|
|
152
|
-
const expected = tokenRaw(P);
|
|
153
|
-
if (!constantTimeEqual(token, expected)) {
|
|
154
|
-
throw new VerificationFailure();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// ---------------------------------------------------------------------------
|
|
159
74
|
// ServerDerivedPublicKey
|
|
160
75
|
// ---------------------------------------------------------------------------
|
|
161
76
|
/**
|
|
162
|
-
* The public
|
|
77
|
+
* The server's public key for one endorsement context.
|
|
163
78
|
*
|
|
164
79
|
* Derived from a {@link ServerRootPublicKey}.
|
|
165
80
|
*/
|
|
@@ -215,36 +130,6 @@ export class EndorsementResponse {
|
|
|
215
130
|
this.R = R;
|
|
216
131
|
this.proof = proof;
|
|
217
132
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Issues an endorsement for every point in `hiddenAttributePoints`,
|
|
220
|
-
* along with a batch proof of validity.
|
|
221
|
-
*
|
|
222
|
-
* The order of the points matters. The endorsements eventually received
|
|
223
|
-
* by the client will be in the same order.
|
|
224
|
-
*/
|
|
225
|
-
static issue(hiddenAttributePoints, privateKey, randomness) {
|
|
226
|
-
if (randomness.length < RANDOMNESS_LEN) {
|
|
227
|
-
throw new Error(`EndorsementResponse.issue: need ${RANDOMNESS_LEN} bytes of randomness`);
|
|
228
|
-
}
|
|
229
|
-
const E = hiddenAttributePoints;
|
|
230
|
-
// R_i = sk_prime * E_i
|
|
231
|
-
const RPoints = E.map((Ei) => Ei.multiply(privateKey.skPrime));
|
|
232
|
-
const RCompressed = RPoints.map((r) => r.toBytes());
|
|
233
|
-
const weightsForProof = generateWeightsForProof(privateKey.public, E, RCompressed);
|
|
234
|
-
// weighted_sum(E) = E[0] + sum(weights[i] * E[i+1])
|
|
235
|
-
const sumE = weightedSum(E, weightsForProof);
|
|
236
|
-
// weighted_sum(R) = sk_prime * weighted_sum(E)
|
|
237
|
-
const sumR = sumE.multiply(privateKey.skPrime);
|
|
238
|
-
const statement = proofStatement();
|
|
239
|
-
const pointArgs = new PointArgs();
|
|
240
|
-
pointArgs.add('weighted_sum(E)', sumE);
|
|
241
|
-
pointArgs.add('weighted_sum(R)', sumR);
|
|
242
|
-
pointArgs.add('PK_prime', privateKey.public.PK_prime);
|
|
243
|
-
const scalarArgs = new ScalarArgs();
|
|
244
|
-
scalarArgs.add('sk_prime', privateKey.skPrime);
|
|
245
|
-
const proof = statement.prove(scalarArgs, pointArgs, new Uint8Array(0), randomness);
|
|
246
|
-
return new EndorsementResponse(RCompressed, proof);
|
|
247
|
-
}
|
|
248
133
|
/**
|
|
249
134
|
* Validates and retrieves the endorsements stored in this response.
|
|
250
135
|
*
|
|
@@ -290,21 +175,6 @@ export class EndorsementResponse {
|
|
|
290
175
|
compressed: compressedEndorsements,
|
|
291
176
|
};
|
|
292
177
|
}
|
|
293
|
-
/**
|
|
294
|
-
* Serialize to bytes: [count(u32 LE)] [R_0..R_n (32 each)] [proof]
|
|
295
|
-
*/
|
|
296
|
-
toBytes() {
|
|
297
|
-
const count = this.R.length;
|
|
298
|
-
const proofLen = this.proof.length;
|
|
299
|
-
const buf = new Uint8Array(4 + count * 32 + proofLen);
|
|
300
|
-
const view = new DataView(buf.buffer);
|
|
301
|
-
view.setUint32(0, count, true);
|
|
302
|
-
for (let i = 0; i < count; i++) {
|
|
303
|
-
buf.set(this.R[i], 4 + i * 32);
|
|
304
|
-
}
|
|
305
|
-
buf.set(this.proof, 4 + count * 32);
|
|
306
|
-
return buf;
|
|
307
|
-
}
|
|
308
178
|
/**
|
|
309
179
|
* Deserialize from bytes.
|
|
310
180
|
*/
|