@open-e2ee/signal-protocol-sdk 0.1.0-alpha.1
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 +195 -0
- package/ARCHITECTURE.md +206 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +661 -0
- package/NOTICE +27 -0
- package/README.md +152 -0
- package/SECURITY.md +125 -0
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/TROUBLESHOOTING.md +203 -0
- package/blocking/README.md +42 -0
- package/client/README.md +169 -0
- package/device/README.md +166 -0
- package/dist/blocking/index.d.ts +4 -0
- package/dist/blocking/index.d.ts.map +1 -0
- package/dist/blocking/index.js +2 -0
- package/dist/blocking/index.js.map +1 -0
- package/dist/blocking/manager.d.ts +27 -0
- package/dist/blocking/manager.d.ts.map +1 -0
- package/dist/blocking/manager.js +61 -0
- package/dist/blocking/manager.js.map +1 -0
- package/dist/blocking/types.d.ts +43 -0
- package/dist/blocking/types.d.ts.map +1 -0
- package/dist/blocking/types.js +9 -0
- package/dist/blocking/types.js.map +1 -0
- package/dist/client/client.d.ts +1281 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +2296 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/compose.d.ts +105 -0
- package/dist/client/compose.d.ts.map +1 -0
- package/dist/client/compose.js +41 -0
- package/dist/client/compose.js.map +1 -0
- package/dist/client/config.d.ts +707 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +19 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/constants.d.ts +48 -0
- package/dist/client/constants.d.ts.map +1 -0
- package/dist/client/constants.js +40 -0
- package/dist/client/constants.js.map +1 -0
- package/dist/client/content-adapter.d.ts +106 -0
- package/dist/client/content-adapter.d.ts.map +1 -0
- package/dist/client/content-adapter.js +423 -0
- package/dist/client/content-adapter.js.map +1 -0
- package/dist/client/dual-store.d.ts +70 -0
- package/dist/client/dual-store.d.ts.map +1 -0
- package/dist/client/dual-store.js +123 -0
- package/dist/client/dual-store.js.map +1 -0
- package/dist/client/endorsement-manager.d.ts +143 -0
- package/dist/client/endorsement-manager.d.ts.map +1 -0
- package/dist/client/endorsement-manager.js +259 -0
- package/dist/client/endorsement-manager.js.map +1 -0
- package/dist/client/event-hooks.d.ts +330 -0
- package/dist/client/event-hooks.d.ts.map +1 -0
- package/dist/client/event-hooks.js +59 -0
- package/dist/client/event-hooks.js.map +1 -0
- package/dist/client/files.d.ts +73 -0
- package/dist/client/files.d.ts.map +1 -0
- package/dist/client/files.js +192 -0
- package/dist/client/files.js.map +1 -0
- package/dist/client/groups.d.ts +204 -0
- package/dist/client/groups.d.ts.map +1 -0
- package/dist/client/groups.js +340 -0
- package/dist/client/groups.js.map +1 -0
- package/dist/client/headless.d.ts +99 -0
- package/dist/client/headless.d.ts.map +1 -0
- package/dist/client/headless.js +163 -0
- package/dist/client/headless.js.map +1 -0
- package/dist/client/index.d.ts +33 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/key-rotation-core.d.ts +167 -0
- package/dist/client/key-rotation-core.d.ts.map +1 -0
- package/dist/client/key-rotation-core.js +459 -0
- package/dist/client/key-rotation-core.js.map +1 -0
- package/dist/client/key-rotation.d.ts +45 -0
- package/dist/client/key-rotation.d.ts.map +1 -0
- package/dist/client/key-rotation.js +174 -0
- package/dist/client/key-rotation.js.map +1 -0
- package/dist/client/media.d.ts +173 -0
- package/dist/client/media.d.ts.map +1 -0
- package/dist/client/media.js +476 -0
- package/dist/client/media.js.map +1 -0
- package/dist/client/messages.d.ts +131 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +546 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/multi-device.d.ts +73 -0
- package/dist/client/multi-device.d.ts.map +1 -0
- package/dist/client/multi-device.js +104 -0
- package/dist/client/multi-device.js.map +1 -0
- package/dist/client/prekeys.d.ts +133 -0
- package/dist/client/prekeys.d.ts.map +1 -0
- package/dist/client/prekeys.js +608 -0
- package/dist/client/prekeys.js.map +1 -0
- package/dist/client/relay-subscription.d.ts +83 -0
- package/dist/client/relay-subscription.d.ts.map +1 -0
- package/dist/client/relay-subscription.js +353 -0
- package/dist/client/relay-subscription.js.map +1 -0
- package/dist/client/retry-utils.d.ts +42 -0
- package/dist/client/retry-utils.d.ts.map +1 -0
- package/dist/client/retry-utils.js +107 -0
- package/dist/client/retry-utils.js.map +1 -0
- package/dist/client/retry.d.ts +121 -0
- package/dist/client/retry.d.ts.map +1 -0
- package/dist/client/retry.js +499 -0
- package/dist/client/retry.js.map +1 -0
- package/dist/client/sealed-sender-ops.d.ts +61 -0
- package/dist/client/sealed-sender-ops.d.ts.map +1 -0
- package/dist/client/sealed-sender-ops.js +173 -0
- package/dist/client/sealed-sender-ops.js.map +1 -0
- package/dist/client/sessions.d.ts +108 -0
- package/dist/client/sessions.d.ts.map +1 -0
- package/dist/client/sessions.js +367 -0
- package/dist/client/sessions.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +331 -0
- package/dist/client/signal-service-cipher.d.ts.map +1 -0
- package/dist/client/signal-service-cipher.js +1506 -0
- package/dist/client/signal-service-cipher.js.map +1 -0
- package/dist/client/state.d.ts +147 -0
- package/dist/client/state.d.ts.map +1 -0
- package/dist/client/state.js +226 -0
- package/dist/client/state.js.map +1 -0
- package/dist/client/types.d.ts +423 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +42 -0
- package/dist/client/types.js.map +1 -0
- package/dist/device/connection.d.ts +46 -0
- package/dist/device/connection.d.ts.map +1 -0
- package/dist/device/connection.js +239 -0
- package/dist/device/connection.js.map +1 -0
- package/dist/device/constants.d.ts +69 -0
- package/dist/device/constants.d.ts.map +1 -0
- package/dist/device/constants.js +64 -0
- package/dist/device/constants.js.map +1 -0
- package/dist/device/device-id.d.ts +45 -0
- package/dist/device/device-id.d.ts.map +1 -0
- package/dist/device/device-id.js +87 -0
- package/dist/device/device-id.js.map +1 -0
- package/dist/device/device-name-crypto.d.ts +39 -0
- package/dist/device/device-name-crypto.d.ts.map +1 -0
- package/dist/device/device-name-crypto.js +165 -0
- package/dist/device/device-name-crypto.js.map +1 -0
- package/dist/device/index.d.ts +31 -0
- package/dist/device/index.d.ts.map +1 -0
- package/dist/device/index.js +35 -0
- package/dist/device/index.js.map +1 -0
- package/dist/device/lifecycle/index.d.ts +25 -0
- package/dist/device/lifecycle/index.d.ts.map +1 -0
- package/dist/device/lifecycle/index.js +3 -0
- package/dist/device/lifecycle/index.js.map +1 -0
- package/dist/device/lifecycle/manager.d.ts +273 -0
- package/dist/device/lifecycle/manager.d.ts.map +1 -0
- package/dist/device/lifecycle/manager.js +1229 -0
- package/dist/device/lifecycle/manager.js.map +1 -0
- package/dist/device/lifecycle/types.d.ts +372 -0
- package/dist/device/lifecycle/types.d.ts.map +1 -0
- package/dist/device/lifecycle/types.js +10 -0
- package/dist/device/lifecycle/types.js.map +1 -0
- package/dist/device/lifecycle/utils.d.ts +37 -0
- package/dist/device/lifecycle/utils.d.ts.map +1 -0
- package/dist/device/lifecycle/utils.js +79 -0
- package/dist/device/lifecycle/utils.js.map +1 -0
- package/dist/device/provisioning.d.ts +249 -0
- package/dist/device/provisioning.d.ts.map +1 -0
- package/dist/device/provisioning.js +439 -0
- package/dist/device/provisioning.js.map +1 -0
- package/dist/device/transfer.d.ts +231 -0
- package/dist/device/transfer.d.ts.map +1 -0
- package/dist/device/transfer.js +628 -0
- package/dist/device/transfer.js.map +1 -0
- package/dist/device/types.d.ts +275 -0
- package/dist/device/types.d.ts.map +1 -0
- package/dist/device/types.js +42 -0
- package/dist/device/types.js.map +1 -0
- package/dist/encoding/base64.d.ts +14 -0
- package/dist/encoding/base64.d.ts.map +1 -0
- package/dist/encoding/base64.js +2 -0
- package/dist/encoding/base64.js.map +1 -0
- package/dist/encoding/hex.d.ts +14 -0
- package/dist/encoding/hex.d.ts.map +1 -0
- package/dist/encoding/hex.js +2 -0
- package/dist/encoding/hex.js.map +1 -0
- package/dist/encoding/index.d.ts +17 -0
- package/dist/encoding/index.d.ts.map +1 -0
- package/dist/encoding/index.js +3 -0
- package/dist/encoding/index.js.map +1 -0
- package/dist/files/index.d.ts +16 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +15 -0
- package/dist/files/index.js.map +1 -0
- package/dist/groups/index.d.ts +12 -0
- package/dist/groups/index.d.ts.map +1 -0
- package/dist/groups/index.js +9 -0
- package/dist/groups/index.js.map +1 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-connection-presence.d.ts +68 -0
- package/dist/hooks/use-connection-presence.d.ts.map +1 -0
- package/dist/hooks/use-connection-presence.js +300 -0
- package/dist/hooks/use-connection-presence.js.map +1 -0
- package/dist/hooks/use-group-membership.d.ts +66 -0
- package/dist/hooks/use-group-membership.d.ts.map +1 -0
- package/dist/hooks/use-group-membership.js +156 -0
- package/dist/hooks/use-group-membership.js.map +1 -0
- package/dist/hooks/use-key-rotation.d.ts +119 -0
- package/dist/hooks/use-key-rotation.d.ts.map +1 -0
- package/dist/hooks/use-key-rotation.js +198 -0
- package/dist/hooks/use-key-rotation.js.map +1 -0
- package/dist/hooks/use-session-health.d.ts +51 -0
- package/dist/hooks/use-session-health.d.ts.map +1 -0
- package/dist/hooks/use-session-health.js +59 -0
- package/dist/hooks/use-session-health.js.map +1 -0
- package/dist/hooks/use-single-flight.d.ts +29 -0
- package/dist/hooks/use-single-flight.d.ts.map +1 -0
- package/dist/hooks/use-single-flight.js +59 -0
- package/dist/hooks/use-single-flight.js.map +1 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +169 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/crypto/ec/ed25519.d.ts +78 -0
- package/dist/internal/crypto/ec/ed25519.d.ts.map +1 -0
- package/dist/internal/crypto/ec/ed25519.js +108 -0
- package/dist/internal/crypto/ec/ed25519.js.map +1 -0
- package/dist/internal/crypto/ec/index.d.ts +5 -0
- package/dist/internal/crypto/ec/index.d.ts.map +1 -0
- package/dist/internal/crypto/ec/index.js +4 -0
- package/dist/internal/crypto/ec/index.js.map +1 -0
- package/dist/internal/crypto/ec/x25519-validation.d.ts +70 -0
- package/dist/internal/crypto/ec/x25519-validation.d.ts.map +1 -0
- package/dist/internal/crypto/ec/x25519-validation.js +137 -0
- package/dist/internal/crypto/ec/x25519-validation.js.map +1 -0
- package/dist/internal/crypto/ec/x25519.d.ts +91 -0
- package/dist/internal/crypto/ec/x25519.d.ts.map +1 -0
- package/dist/internal/crypto/ec/x25519.js +124 -0
- package/dist/internal/crypto/ec/x25519.js.map +1 -0
- package/dist/internal/crypto/hash/index.d.ts +4 -0
- package/dist/internal/crypto/hash/index.d.ts.map +1 -0
- package/dist/internal/crypto/hash/index.js +3 -0
- package/dist/internal/crypto/hash/index.js.map +1 -0
- package/dist/internal/crypto/hash/sha256.d.ts +24 -0
- package/dist/internal/crypto/hash/sha256.d.ts.map +1 -0
- package/dist/internal/crypto/hash/sha256.js +23 -0
- package/dist/internal/crypto/hash/sha256.js.map +1 -0
- package/dist/internal/crypto/hash/sha512.d.ts +16 -0
- package/dist/internal/crypto/hash/sha512.d.ts.map +1 -0
- package/dist/internal/crypto/hash/sha512.js +27 -0
- package/dist/internal/crypto/hash/sha512.js.map +1 -0
- package/dist/internal/crypto/index.d.ts +60 -0
- package/dist/internal/crypto/index.d.ts.map +1 -0
- package/dist/internal/crypto/index.js +107 -0
- package/dist/internal/crypto/index.js.map +1 -0
- package/dist/internal/crypto/kdf/hkdf.d.ts +300 -0
- package/dist/internal/crypto/kdf/hkdf.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/hkdf.js +452 -0
- package/dist/internal/crypto/kdf/hkdf.js.map +1 -0
- package/dist/internal/crypto/kdf/index.d.ts +4 -0
- package/dist/internal/crypto/kdf/index.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/index.js +3 -0
- package/dist/internal/crypto/kdf/index.js.map +1 -0
- package/dist/internal/crypto/kdf/pbkdf2.d.ts +42 -0
- package/dist/internal/crypto/kdf/pbkdf2.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/pbkdf2.js +44 -0
- package/dist/internal/crypto/kdf/pbkdf2.js.map +1 -0
- package/dist/internal/crypto/key-prefix.d.ts +82 -0
- package/dist/internal/crypto/key-prefix.d.ts.map +1 -0
- package/dist/internal/crypto/key-prefix.js +116 -0
- package/dist/internal/crypto/key-prefix.js.map +1 -0
- package/dist/internal/crypto/pq/index.d.ts +3 -0
- package/dist/internal/crypto/pq/index.d.ts.map +1 -0
- package/dist/internal/crypto/pq/index.js +2 -0
- package/dist/internal/crypto/pq/index.js.map +1 -0
- package/dist/internal/crypto/pq/kyber.d.ts +232 -0
- package/dist/internal/crypto/pq/kyber.d.ts.map +1 -0
- package/dist/internal/crypto/pq/kyber.js +317 -0
- package/dist/internal/crypto/pq/kyber.js.map +1 -0
- package/dist/internal/crypto/random.d.ts +22 -0
- package/dist/internal/crypto/random.d.ts.map +1 -0
- package/dist/internal/crypto/random.js +45 -0
- package/dist/internal/crypto/random.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes-ctr.d.ts +73 -0
- package/dist/internal/crypto/symmetric/aes-ctr.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes-ctr.js +98 -0
- package/dist/internal/crypto/symmetric/aes-ctr.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts +77 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.js +111 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes.d.ts +211 -0
- package/dist/internal/crypto/symmetric/aes.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes.js +386 -0
- package/dist/internal/crypto/symmetric/aes.js.map +1 -0
- package/dist/internal/crypto/symmetric/hmac.d.ts +32 -0
- package/dist/internal/crypto/symmetric/hmac.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/hmac.js +20 -0
- package/dist/internal/crypto/symmetric/hmac.js.map +1 -0
- package/dist/internal/crypto/symmetric/index.d.ts +9 -0
- package/dist/internal/crypto/symmetric/index.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/index.js +8 -0
- package/dist/internal/crypto/symmetric/index.js.map +1 -0
- package/dist/internal/crypto/symmetric/mac.d.ts +154 -0
- package/dist/internal/crypto/symmetric/mac.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/mac.js +292 -0
- package/dist/internal/crypto/symmetric/mac.js.map +1 -0
- package/dist/internal/crypto/symmetric/padding.d.ts +55 -0
- package/dist/internal/crypto/symmetric/padding.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/padding.js +90 -0
- package/dist/internal/crypto/symmetric/padding.js.map +1 -0
- package/dist/internal/crypto/symmetric/streaming-aead.d.ts +89 -0
- package/dist/internal/crypto/symmetric/streaming-aead.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/streaming-aead.js +253 -0
- package/dist/internal/crypto/symmetric/streaming-aead.js.map +1 -0
- package/dist/internal/crypto/utils.d.ts +119 -0
- package/dist/internal/crypto/utils.d.ts.map +1 -0
- package/dist/internal/crypto/utils.js +366 -0
- package/dist/internal/crypto/utils.js.map +1 -0
- package/dist/internal/crypto/validation.d.ts +45 -0
- package/dist/internal/crypto/validation.d.ts.map +1 -0
- package/dist/internal/crypto/validation.js +37 -0
- package/dist/internal/crypto/validation.js.map +1 -0
- package/dist/internal/encoding/index.d.ts +2 -0
- package/dist/internal/encoding/index.d.ts.map +1 -0
- package/dist/internal/encoding/index.js +2 -0
- package/dist/internal/encoding/index.js.map +1 -0
- package/dist/internal/encoding/proto/envelope.d.ts +120 -0
- package/dist/internal/encoding/proto/envelope.d.ts.map +1 -0
- package/dist/internal/encoding/proto/envelope.js +160 -0
- package/dist/internal/encoding/proto/envelope.js.map +1 -0
- package/dist/internal/encoding/proto/index.d.ts +25 -0
- package/dist/internal/encoding/proto/index.d.ts.map +1 -0
- package/dist/internal/encoding/proto/index.js +30 -0
- package/dist/internal/encoding/proto/index.js.map +1 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts +118 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts.map +1 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js +383 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -0
- package/dist/internal/encoding/proto/primitives.d.ts +98 -0
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -0
- package/dist/internal/encoding/proto/primitives.js +179 -0
- package/dist/internal/encoding/proto/primitives.js.map +1 -0
- package/dist/internal/encoding/proto/sender-key-message.d.ts +147 -0
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -0
- package/dist/internal/encoding/proto/sender-key-message.js +220 -0
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -0
- package/dist/internal/encoding/proto/signal-message.d.ts +174 -0
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -0
- package/dist/internal/encoding/proto/signal-message.js +372 -0
- package/dist/internal/encoding/proto/signal-message.js.map +1 -0
- package/dist/internal/groups/group-id.d.ts +74 -0
- package/dist/internal/groups/group-id.d.ts.map +1 -0
- package/dist/internal/groups/group-id.js +63 -0
- package/dist/internal/groups/group-id.js.map +1 -0
- package/dist/internal/groups/index.d.ts +15 -0
- package/dist/internal/groups/index.d.ts.map +1 -0
- package/dist/internal/groups/index.js +2 -0
- package/dist/internal/groups/index.js.map +1 -0
- package/dist/internal/groups-v2/access-control.d.ts +101 -0
- package/dist/internal/groups-v2/access-control.d.ts.map +1 -0
- package/dist/internal/groups-v2/access-control.js +184 -0
- package/dist/internal/groups-v2/access-control.js.map +1 -0
- package/dist/internal/groups-v2/change-actions.d.ts +35 -0
- package/dist/internal/groups-v2/change-actions.d.ts.map +1 -0
- package/dist/internal/groups-v2/change-actions.js +358 -0
- package/dist/internal/groups-v2/change-actions.js.map +1 -0
- package/dist/internal/groups-v2/encrypted-state.d.ts +121 -0
- package/dist/internal/groups-v2/encrypted-state.d.ts.map +1 -0
- package/dist/internal/groups-v2/encrypted-state.js +455 -0
- package/dist/internal/groups-v2/encrypted-state.js.map +1 -0
- package/dist/internal/groups-v2/index.d.ts +14 -0
- package/dist/internal/groups-v2/index.d.ts.map +1 -0
- package/dist/internal/groups-v2/index.js +11 -0
- package/dist/internal/groups-v2/index.js.map +1 -0
- package/dist/internal/groups-v2/invite-link.d.ts +55 -0
- package/dist/internal/groups-v2/invite-link.d.ts.map +1 -0
- package/dist/internal/groups-v2/invite-link.js +111 -0
- package/dist/internal/groups-v2/invite-link.js.map +1 -0
- package/dist/internal/groups-v2/manager.d.ts +351 -0
- package/dist/internal/groups-v2/manager.d.ts.map +1 -0
- package/dist/internal/groups-v2/manager.js +1093 -0
- package/dist/internal/groups-v2/manager.js.map +1 -0
- package/dist/internal/groups-v2/types.d.ts +371 -0
- package/dist/internal/groups-v2/types.d.ts.map +1 -0
- package/dist/internal/groups-v2/types.js +61 -0
- package/dist/internal/groups-v2/types.js.map +1 -0
- package/dist/internal/manager/index.d.ts +16 -0
- package/dist/internal/manager/index.d.ts.map +1 -0
- package/dist/internal/manager/index.js +2 -0
- package/dist/internal/manager/index.js.map +1 -0
- package/dist/internal/manager/manager.d.ts +378 -0
- package/dist/internal/manager/manager.d.ts.map +1 -0
- package/dist/internal/manager/manager.js +1079 -0
- package/dist/internal/manager/manager.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/chains.d.ts +135 -0
- package/dist/internal/protocol/double-ratchet/chains.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/chains.js +417 -0
- package/dist/internal/protocol/double-ratchet/chains.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/index.d.ts +20 -0
- package/dist/internal/protocol/double-ratchet/index.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/index.js +21 -0
- package/dist/internal/protocol/double-ratchet/index.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts +231 -0
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/ratchet.js +198 -0
- package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -0
- package/dist/internal/protocol/index.d.ts +24 -0
- package/dist/internal/protocol/index.d.ts.map +1 -0
- package/dist/internal/protocol/index.js +9 -0
- package/dist/internal/protocol/index.js.map +1 -0
- package/dist/internal/protocol/pqxdh/index.d.ts +19 -0
- package/dist/internal/protocol/pqxdh/index.d.ts.map +1 -0
- package/dist/internal/protocol/pqxdh/index.js +16 -0
- package/dist/internal/protocol/pqxdh/index.js.map +1 -0
- package/dist/internal/protocol/pqxdh/pqxdh.d.ts +141 -0
- package/dist/internal/protocol/pqxdh/pqxdh.d.ts.map +1 -0
- package/dist/internal/protocol/pqxdh/pqxdh.js +399 -0
- package/dist/internal/protocol/pqxdh/pqxdh.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/certificate.d.ts +94 -0
- package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/certificate.js +254 -0
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts +46 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.js +184 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption.d.ts +59 -0
- package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption.js +268 -0
- package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +48 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.js +71 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts +56 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.js +169 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption.d.ts +66 -0
- package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption.js +174 -0
- package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/index.d.ts +23 -0
- package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/index.js +61 -0
- package/dist/internal/protocol/sealed-sender/index.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +129 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/proto/index.js +267 -0
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/types.d.ts +461 -0
- package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/types.js +99 -0
- package/dist/internal/protocol/sealed-sender/types.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.d.ts +124 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.js +295 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts +107 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.js +185 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.js.map +1 -0
- package/dist/internal/protocol/sender-keys/index.d.ts +11 -0
- package/dist/internal/protocol/sender-keys/index.d.ts.map +1 -0
- package/dist/internal/protocol/sender-keys/index.js +2 -0
- package/dist/internal/protocol/sender-keys/index.js.map +1 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts +298 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -0
- package/dist/internal/protocol/sender-keys/manager.js +839 -0
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -0
- package/dist/internal/protocol/spqr/braid-serialize.d.ts +128 -0
- package/dist/internal/protocol/spqr/braid-serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/braid-serialize.js +373 -0
- package/dist/internal/protocol/spqr/braid-serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/braid.d.ts +164 -0
- package/dist/internal/protocol/spqr/braid.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/braid.js +305 -0
- package/dist/internal/protocol/spqr/braid.js.map +1 -0
- package/dist/internal/protocol/spqr/index.d.ts +161 -0
- package/dist/internal/protocol/spqr/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/index.js +115 -0
- package/dist/internal/protocol/spqr/index.js.map +1 -0
- package/dist/internal/protocol/spqr/message.d.ts +237 -0
- package/dist/internal/protocol/spqr/message.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/message.js +298 -0
- package/dist/internal/protocol/spqr/message.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts +174 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js +248 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts +29 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js +43 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts +170 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.js +249 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts +84 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js +138 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts +45 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.js +94 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts +52 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js +121 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts +12 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js +15 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +136 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +796 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts +454 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js +790 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts +108 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js +125 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts +12 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js +5 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts +28 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js +13953 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts +40 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js +52 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts +151 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js +297 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts +97 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js +201 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts +249 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js +731 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts +127 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js +894 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +387 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.js +121 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.js.map +1 -0
- package/dist/internal/protocol/spqr/serialize.d.ts +149 -0
- package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/serialize.js +370 -0
- package/dist/internal/protocol/spqr/serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/spqr.d.ts +486 -0
- package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/spqr.js +1031 -0
- package/dist/internal/protocol/spqr/spqr.js.map +1 -0
- package/dist/internal/protocol/spqr/validate.d.ts +35 -0
- package/dist/internal/protocol/spqr/validate.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/validate.js +62 -0
- package/dist/internal/protocol/spqr/validate.js.map +1 -0
- package/dist/internal/protocol/triple-ratchet/index.d.ts +21 -0
- package/dist/internal/protocol/triple-ratchet/index.d.ts.map +1 -0
- package/dist/internal/protocol/triple-ratchet/index.js +19 -0
- package/dist/internal/protocol/triple-ratchet/index.js.map +1 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts +233 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts.map +1 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.js +254 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.js.map +1 -0
- package/dist/internal/protocol/username/generate.d.ts +9 -0
- package/dist/internal/protocol/username/generate.d.ts.map +1 -0
- package/dist/internal/protocol/username/generate.js +16 -0
- package/dist/internal/protocol/username/generate.js.map +1 -0
- package/dist/internal/protocol/username/hash.d.ts +74 -0
- package/dist/internal/protocol/username/hash.d.ts.map +1 -0
- package/dist/internal/protocol/username/hash.js +228 -0
- package/dist/internal/protocol/username/hash.js.map +1 -0
- package/dist/internal/protocol/username/link.d.ts +50 -0
- package/dist/internal/protocol/username/link.d.ts.map +1 -0
- package/dist/internal/protocol/username/link.js +187 -0
- package/dist/internal/protocol/username/link.js.map +1 -0
- package/dist/internal/protocol/username/proof.d.ts +34 -0
- package/dist/internal/protocol/username/proof.d.ts.map +1 -0
- package/dist/internal/protocol/username/proof.js +83 -0
- package/dist/internal/protocol/username/proof.js.map +1 -0
- package/dist/internal/protocol/version.d.ts +184 -0
- package/dist/internal/protocol/version.d.ts.map +1 -0
- package/dist/internal/protocol/version.js +163 -0
- package/dist/internal/protocol/version.js.map +1 -0
- package/dist/internal/protocol/x3dh/index.d.ts +15 -0
- package/dist/internal/protocol/x3dh/index.d.ts.map +1 -0
- package/dist/internal/protocol/x3dh/index.js +13 -0
- package/dist/internal/protocol/x3dh/index.js.map +1 -0
- package/dist/internal/protocol/x3dh/x3dh.d.ts +131 -0
- package/dist/internal/protocol/x3dh/x3dh.d.ts.map +1 -0
- package/dist/internal/protocol/x3dh/x3dh.js +261 -0
- package/dist/internal/protocol/x3dh/x3dh.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/attributes.d.ts +157 -0
- package/dist/internal/protocol/zk/credentials/attributes.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/attributes.js +177 -0
- package/dist/internal/protocol/zk/credentials/attributes.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/credentials.d.ts +129 -0
- package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/credentials.js +204 -0
- package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts +235 -0
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/endorsements.js +520 -0
- package/dist/internal/protocol/zk/credentials/endorsements.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/index.d.ts +14 -0
- package/dist/internal/protocol/zk/credentials/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/index.js +6 -0
- package/dist/internal/protocol/zk/credentials/index.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/issuance.d.ts +135 -0
- package/dist/internal/protocol/zk/credentials/issuance.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/issuance.js +338 -0
- package/dist/internal/protocol/zk/credentials/issuance.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/presentation.d.ts +160 -0
- package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/presentation.js +447 -0
- package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -0
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts +191 -0
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/auth-credential.js +377 -0
- package/dist/internal/protocol/zk/groups/auth-credential.js.map +1 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts +73 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js +140 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js.map +1 -0
- package/dist/internal/protocol/zk/groups/group-params.d.ts +93 -0
- package/dist/internal/protocol/zk/groups/group-params.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/group-params.js +184 -0
- package/dist/internal/protocol/zk/groups/group-params.js.map +1 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts +245 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js +404 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js.map +1 -0
- package/dist/internal/protocol/zk/groups/index.d.ts +19 -0
- package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/index.js +12 -0
- package/dist/internal/protocol/zk/groups/index.js.map +1 -0
- package/dist/internal/protocol/zk/groups/lizard.d.ts +51 -0
- package/dist/internal/protocol/zk/groups/lizard.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/lizard.js +478 -0
- package/dist/internal/protocol/zk/groups/lizard.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts +35 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js +99 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +195 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.js +370 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts +45 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js +125 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts +33 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.js +62 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.d.ts +17 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.js +33 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.js.map +1 -0
- package/dist/internal/protocol/zk/groups/server-params.d.ts +114 -0
- package/dist/internal/protocol/zk/groups/server-params.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/server-params.js +146 -0
- package/dist/internal/protocol/zk/groups/server-params.js.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.d.ts +41 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.js +113 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.js.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-struct.d.ts +48 -0
- package/dist/internal/protocol/zk/groups/uid-struct.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-struct.js +77 -0
- package/dist/internal/protocol/zk/groups/uid-struct.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/args.d.ts +33 -0
- package/dist/internal/protocol/zk/proofs/args.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/args.js +43 -0
- package/dist/internal/protocol/zk/proofs/args.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/index.d.ts +13 -0
- package/dist/internal/protocol/zk/proofs/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/index.js +7 -0
- package/dist/internal/protocol/zk/proofs/index.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/proof.d.ts +30 -0
- package/dist/internal/protocol/zk/proofs/proof.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/proof.js +48 -0
- package/dist/internal/protocol/zk/proofs/proof.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts +34 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.js +138 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts +120 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho.js +221 -0
- package/dist/internal/protocol/zk/proofs/sho.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sign.d.ts +29 -0
- package/dist/internal/protocol/zk/proofs/sign.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sign.js +34 -0
- package/dist/internal/protocol/zk/proofs/sign.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/statement.d.ts +103 -0
- package/dist/internal/protocol/zk/proofs/statement.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/statement.js +282 -0
- package/dist/internal/protocol/zk/proofs/statement.js.map +1 -0
- package/dist/internal/sesame/device-registry.d.ts +208 -0
- package/dist/internal/sesame/device-registry.d.ts.map +1 -0
- package/dist/internal/sesame/device-registry.js +431 -0
- package/dist/internal/sesame/device-registry.js.map +1 -0
- package/dist/internal/sesame/index.d.ts +31 -0
- package/dist/internal/sesame/index.d.ts.map +1 -0
- package/dist/internal/sesame/index.js +40 -0
- package/dist/internal/sesame/index.js.map +1 -0
- package/dist/internal/sesame/manager.d.ts +351 -0
- package/dist/internal/sesame/manager.d.ts.map +1 -0
- package/dist/internal/sesame/manager.js +1760 -0
- package/dist/internal/sesame/manager.js.map +1 -0
- package/dist/internal/sesame/types.d.ts +840 -0
- package/dist/internal/sesame/types.d.ts.map +1 -0
- package/dist/internal/sesame/types.js +290 -0
- package/dist/internal/sesame/types.js.map +1 -0
- package/dist/internal/sesame/validation.d.ts +72 -0
- package/dist/internal/sesame/validation.d.ts.map +1 -0
- package/dist/internal/sesame/validation.js +136 -0
- package/dist/internal/sesame/validation.js.map +1 -0
- package/dist/internal/session/builder.d.ts +94 -0
- package/dist/internal/session/builder.d.ts.map +1 -0
- package/dist/internal/session/builder.js +266 -0
- package/dist/internal/session/builder.js.map +1 -0
- package/dist/internal/session/cipher.d.ts +256 -0
- package/dist/internal/session/cipher.d.ts.map +1 -0
- package/dist/internal/session/cipher.js +1222 -0
- package/dist/internal/session/cipher.js.map +1 -0
- package/dist/internal/session/decryption.d.ts +37 -0
- package/dist/internal/session/decryption.d.ts.map +1 -0
- package/dist/internal/session/decryption.js +256 -0
- package/dist/internal/session/decryption.js.map +1 -0
- package/dist/internal/session/factory.d.ts +161 -0
- package/dist/internal/session/factory.d.ts.map +1 -0
- package/dist/internal/session/factory.js +211 -0
- package/dist/internal/session/factory.js.map +1 -0
- package/dist/internal/session/handshake.d.ts +72 -0
- package/dist/internal/session/handshake.d.ts.map +1 -0
- package/dist/internal/session/handshake.js +343 -0
- package/dist/internal/session/handshake.js.map +1 -0
- package/dist/internal/session/identity-binding.d.ts +5 -0
- package/dist/internal/session/identity-binding.d.ts.map +1 -0
- package/dist/internal/session/identity-binding.js +15 -0
- package/dist/internal/session/identity-binding.js.map +1 -0
- package/dist/internal/session/index.d.ts +73 -0
- package/dist/internal/session/index.d.ts.map +1 -0
- package/dist/internal/session/index.js +75 -0
- package/dist/internal/session/index.js.map +1 -0
- package/dist/internal/session/keys.d.ts +220 -0
- package/dist/internal/session/keys.d.ts.map +1 -0
- package/dist/internal/session/keys.js +78 -0
- package/dist/internal/session/keys.js.map +1 -0
- package/dist/internal/session/ratchet.d.ts +97 -0
- package/dist/internal/session/ratchet.d.ts.map +1 -0
- package/dist/internal/session/ratchet.js +187 -0
- package/dist/internal/session/ratchet.js.map +1 -0
- package/dist/internal/session/session-resolver.d.ts +138 -0
- package/dist/internal/session/session-resolver.d.ts.map +1 -0
- package/dist/internal/session/session-resolver.js +190 -0
- package/dist/internal/session/session-resolver.js.map +1 -0
- package/dist/internal/session/state.d.ts +278 -0
- package/dist/internal/session/state.d.ts.map +1 -0
- package/dist/internal/session/state.js +167 -0
- package/dist/internal/session/state.js.map +1 -0
- package/dist/internal/session/types.d.ts +192 -0
- package/dist/internal/session/types.d.ts.map +1 -0
- package/dist/internal/session/types.js +16 -0
- package/dist/internal/session/types.js.map +1 -0
- package/dist/internal/session/validation.d.ts +145 -0
- package/dist/internal/session/validation.d.ts.map +1 -0
- package/dist/internal/session/validation.js +340 -0
- package/dist/internal/session/validation.js.map +1 -0
- package/dist/keys/branded.d.ts +85 -0
- package/dist/keys/branded.d.ts.map +1 -0
- package/dist/keys/branded.js +26 -0
- package/dist/keys/branded.js.map +1 -0
- package/dist/keys/generation.d.ts +101 -0
- package/dist/keys/generation.d.ts.map +1 -0
- package/dist/keys/generation.js +181 -0
- package/dist/keys/generation.js.map +1 -0
- package/dist/keys/identity.d.ts +27 -0
- package/dist/keys/identity.d.ts.map +1 -0
- package/dist/keys/identity.js +200 -0
- package/dist/keys/identity.js.map +1 -0
- package/dist/keys/index.d.ts +24 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +22 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/keys/prekey-signature.d.ts +13 -0
- package/dist/keys/prekey-signature.d.ts.map +1 -0
- package/dist/keys/prekey-signature.js +46 -0
- package/dist/keys/prekey-signature.js.map +1 -0
- package/dist/keys/types.d.ts +255 -0
- package/dist/keys/types.d.ts.map +1 -0
- package/dist/keys/types.js +11 -0
- package/dist/keys/types.js.map +1 -0
- package/dist/layers.d.ts +228 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +328 -0
- package/dist/layers.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +243 -0
- package/dist/local/store/expo/adapter.d.ts.map +1 -0
- package/dist/local/store/expo/adapter.js +619 -0
- package/dist/local/store/expo/adapter.js.map +1 -0
- package/dist/local/store/expo/database-key.d.ts +142 -0
- package/dist/local/store/expo/database-key.d.ts.map +1 -0
- package/dist/local/store/expo/database-key.js +312 -0
- package/dist/local/store/expo/database-key.js.map +1 -0
- package/dist/local/store/expo/db.d.ts +92 -0
- package/dist/local/store/expo/db.d.ts.map +1 -0
- package/dist/local/store/expo/db.js +142 -0
- package/dist/local/store/expo/db.js.map +1 -0
- package/dist/local/store/expo/index.d.ts +22 -0
- package/dist/local/store/expo/index.d.ts.map +1 -0
- package/dist/local/store/expo/index.js +10 -0
- package/dist/local/store/expo/index.js.map +1 -0
- package/dist/local/store/expo/key-storage.d.ts +422 -0
- package/dist/local/store/expo/key-storage.d.ts.map +1 -0
- package/dist/local/store/expo/key-storage.js +1292 -0
- package/dist/local/store/expo/key-storage.js.map +1 -0
- package/dist/local/store/expo/maintenance.d.ts +4 -0
- package/dist/local/store/expo/maintenance.d.ts.map +1 -0
- package/dist/local/store/expo/maintenance.js +36 -0
- package/dist/local/store/expo/maintenance.js.map +1 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts +155 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.js +309 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.js.map +1 -0
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts +189 -0
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/ec-signed-prekey.js +359 -0
- package/dist/local/store/expo/models/ec-signed-prekey.js.map +1 -0
- package/dist/local/store/expo/models/identity-key-id.d.ts +9 -0
- package/dist/local/store/expo/models/identity-key-id.d.ts.map +1 -0
- package/dist/local/store/expo/models/identity-key-id.js +10 -0
- package/dist/local/store/expo/models/identity-key-id.js.map +1 -0
- package/dist/local/store/expo/models/index.d.ts +20 -0
- package/dist/local/store/expo/models/index.d.ts.map +1 -0
- package/dist/local/store/expo/models/index.js +80 -0
- package/dist/local/store/expo/models/index.js.map +1 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts +183 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.js +353 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts +37 -0
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey-used.js +59 -0
- package/dist/local/store/expo/models/kyber-prekey-used.js.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey.d.ts +172 -0
- package/dist/local/store/expo/models/kyber-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey.js +314 -0
- package/dist/local/store/expo/models/kyber-prekey.js.map +1 -0
- package/dist/local/store/expo/models/local-identity.d.ts +52 -0
- package/dist/local/store/expo/models/local-identity.d.ts.map +1 -0
- package/dist/local/store/expo/models/local-identity.js +166 -0
- package/dist/local/store/expo/models/local-identity.js.map +1 -0
- package/dist/local/store/expo/models/message-record.d.ts +198 -0
- package/dist/local/store/expo/models/message-record.d.ts.map +1 -0
- package/dist/local/store/expo/models/message-record.js +298 -0
- package/dist/local/store/expo/models/message-record.js.map +1 -0
- package/dist/local/store/expo/models/recipient-identity.d.ts +21 -0
- package/dist/local/store/expo/models/recipient-identity.d.ts.map +1 -0
- package/dist/local/store/expo/models/recipient-identity.js +66 -0
- package/dist/local/store/expo/models/recipient-identity.js.map +1 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +33 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +1 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.js +54 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.js.map +1 -0
- package/dist/local/store/expo/models/sender-key.d.ts +210 -0
- package/dist/local/store/expo/models/sender-key.d.ts.map +1 -0
- package/dist/local/store/expo/models/sender-key.js +379 -0
- package/dist/local/store/expo/models/sender-key.js.map +1 -0
- package/dist/local/store/expo/models/session.d.ts +175 -0
- package/dist/local/store/expo/models/session.d.ts.map +1 -0
- package/dist/local/store/expo/models/session.js +496 -0
- package/dist/local/store/expo/models/session.js.map +1 -0
- package/dist/local/store/expo/schema.d.ts +1734 -0
- package/dist/local/store/expo/schema.d.ts.map +1 -0
- package/dist/local/store/expo/schema.js +155 -0
- package/dist/local/store/expo/schema.js.map +1 -0
- package/dist/local/store/expo/secure-store-options.d.ts +10 -0
- package/dist/local/store/expo/secure-store-options.d.ts.map +1 -0
- package/dist/local/store/expo/secure-store-options.js +5 -0
- package/dist/local/store/expo/secure-store-options.js.map +1 -0
- package/dist/local/store/index.d.ts +41 -0
- package/dist/local/store/index.d.ts.map +1 -0
- package/dist/local/store/index.js +34 -0
- package/dist/local/store/index.js.map +1 -0
- package/dist/local/store/mock/adapter.d.ts +185 -0
- package/dist/local/store/mock/adapter.d.ts.map +1 -0
- package/dist/local/store/mock/adapter.js +875 -0
- package/dist/local/store/mock/adapter.js.map +1 -0
- package/dist/local/store/mock/index.d.ts +10 -0
- package/dist/local/store/mock/index.d.ts.map +1 -0
- package/dist/local/store/mock/index.js +6 -0
- package/dist/local/store/mock/index.js.map +1 -0
- package/dist/local/store/node/adapter.d.ts +85 -0
- package/dist/local/store/node/adapter.d.ts.map +1 -0
- package/dist/local/store/node/adapter.js +274 -0
- package/dist/local/store/node/adapter.js.map +1 -0
- package/dist/local/store/node/database-encryption.d.ts +109 -0
- package/dist/local/store/node/database-encryption.d.ts.map +1 -0
- package/dist/local/store/node/database-encryption.js +202 -0
- package/dist/local/store/node/database-encryption.js.map +1 -0
- package/dist/local/store/node/database-key.d.ts +124 -0
- package/dist/local/store/node/database-key.d.ts.map +1 -0
- package/dist/local/store/node/database-key.js +264 -0
- package/dist/local/store/node/database-key.js.map +1 -0
- package/dist/local/store/node/database.d.ts +156 -0
- package/dist/local/store/node/database.d.ts.map +1 -0
- package/dist/local/store/node/database.js +630 -0
- package/dist/local/store/node/database.js.map +1 -0
- package/dist/local/store/node/index.d.ts +11 -0
- package/dist/local/store/node/index.d.ts.map +1 -0
- package/dist/local/store/node/index.js +8 -0
- package/dist/local/store/node/index.js.map +1 -0
- package/dist/local/store/react-native/adapter.d.ts +240 -0
- package/dist/local/store/react-native/adapter.d.ts.map +1 -0
- package/dist/local/store/react-native/adapter.js +1108 -0
- package/dist/local/store/react-native/adapter.js.map +1 -0
- package/dist/local/store/react-native/index.d.ts +19 -0
- package/dist/local/store/react-native/index.d.ts.map +1 -0
- package/dist/local/store/react-native/index.js +6 -0
- package/dist/local/store/react-native/index.js.map +1 -0
- package/dist/local/store/react-native/storage.d.ts +39 -0
- package/dist/local/store/react-native/storage.d.ts.map +1 -0
- package/dist/local/store/react-native/storage.js +2 -0
- package/dist/local/store/react-native/storage.js.map +1 -0
- package/dist/local/store/session-codec.d.ts +5 -0
- package/dist/local/store/session-codec.d.ts.map +1 -0
- package/dist/local/store/session-codec.js +42 -0
- package/dist/local/store/session-codec.js.map +1 -0
- package/dist/local/store/web/adapter.d.ts +190 -0
- package/dist/local/store/web/adapter.d.ts.map +1 -0
- package/dist/local/store/web/adapter.js +1188 -0
- package/dist/local/store/web/adapter.js.map +1 -0
- package/dist/local/store/web/index.d.ts +11 -0
- package/dist/local/store/web/index.d.ts.map +1 -0
- package/dist/local/store/web/index.js +8 -0
- package/dist/local/store/web/index.js.map +1 -0
- package/dist/local/vault/expo-secure-store.d.ts +10 -0
- package/dist/local/vault/expo-secure-store.d.ts.map +1 -0
- package/dist/local/vault/expo-secure-store.js +23 -0
- package/dist/local/vault/expo-secure-store.js.map +1 -0
- package/dist/local/vault/index.d.ts +7 -0
- package/dist/local/vault/index.d.ts.map +1 -0
- package/dist/local/vault/index.js +2 -0
- package/dist/local/vault/index.js.map +1 -0
- package/dist/logger.d.ts +18 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +71 -0
- package/dist/logger.js.map +1 -0
- package/dist/media/index.d.ts +524 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +2053 -0
- package/dist/media/index.js.map +1 -0
- package/dist/profile/cipher.d.ts +125 -0
- package/dist/profile/cipher.d.ts.map +1 -0
- package/dist/profile/cipher.js +197 -0
- package/dist/profile/cipher.js.map +1 -0
- package/dist/profile/contact-state.d.ts +33 -0
- package/dist/profile/contact-state.d.ts.map +1 -0
- package/dist/profile/contact-state.js +77 -0
- package/dist/profile/contact-state.js.map +1 -0
- package/dist/profile/crypto.d.ts +65 -0
- package/dist/profile/crypto.d.ts.map +1 -0
- package/dist/profile/crypto.js +93 -0
- package/dist/profile/crypto.js.map +1 -0
- package/dist/profile/index.d.ts +26 -0
- package/dist/profile/index.d.ts.map +1 -0
- package/dist/profile/index.js +30 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/profile-key.d.ts +102 -0
- package/dist/profile/profile-key.d.ts.map +1 -0
- package/dist/profile/profile-key.js +229 -0
- package/dist/profile/profile-key.js.map +1 -0
- package/dist/profile/storage.d.ts +61 -0
- package/dist/profile/storage.d.ts.map +1 -0
- package/dist/profile/storage.js +145 -0
- package/dist/profile/storage.js.map +1 -0
- package/dist/profile/update-service.d.ts +53 -0
- package/dist/profile/update-service.d.ts.map +1 -0
- package/dist/profile/update-service.js +67 -0
- package/dist/profile/update-service.js.map +1 -0
- package/dist/remote/object-store/convex-r2/index.d.ts +11 -0
- package/dist/remote/object-store/convex-r2/index.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/index.js +13 -0
- package/dist/remote/object-store/convex-r2/index.js.map +1 -0
- package/dist/remote/object-store/convex-r2/server/index.d.ts +2 -0
- package/dist/remote/object-store/convex-r2/server/index.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/server/index.js +2 -0
- package/dist/remote/object-store/convex-r2/server/index.js.map +1 -0
- package/dist/remote/object-store/convex-r2/server.d.ts +126 -0
- package/dist/remote/object-store/convex-r2/server.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/server.js +232 -0
- package/dist/remote/object-store/convex-r2/server.js.map +1 -0
- package/dist/remote/object-store/convex-r2/storage.d.ts +47 -0
- package/dist/remote/object-store/convex-r2/storage.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/storage.js +55 -0
- package/dist/remote/object-store/convex-r2/storage.js.map +1 -0
- package/dist/remote/object-store/index.d.ts +8 -0
- package/dist/remote/object-store/index.d.ts.map +1 -0
- package/dist/remote/object-store/index.js +2 -0
- package/dist/remote/object-store/index.js.map +1 -0
- package/dist/remote/object-store/s3/index.d.ts +8 -0
- package/dist/remote/object-store/s3/index.d.ts.map +1 -0
- package/dist/remote/object-store/s3/index.js +10 -0
- package/dist/remote/object-store/s3/index.js.map +1 -0
- package/dist/remote/object-store/s3/storage.d.ts +44 -0
- package/dist/remote/object-store/s3/storage.d.ts.map +1 -0
- package/dist/remote/object-store/s3/storage.js +41 -0
- package/dist/remote/object-store/s3/storage.js.map +1 -0
- package/dist/remote/object-store/types.d.ts +80 -0
- package/dist/remote/object-store/types.d.ts.map +1 -0
- package/dist/remote/object-store/types.js +2 -0
- package/dist/remote/object-store/types.js.map +1 -0
- package/dist/remote/object-store/validation.d.ts +6 -0
- package/dist/remote/object-store/validation.d.ts.map +1 -0
- package/dist/remote/object-store/validation.js +93 -0
- package/dist/remote/object-store/validation.js.map +1 -0
- package/dist/remote/relay/convex/group-server.d.ts +118 -0
- package/dist/remote/relay/convex/group-server.d.ts.map +1 -0
- package/dist/remote/relay/convex/group-server.js +150 -0
- package/dist/remote/relay/convex/group-server.js.map +1 -0
- package/dist/remote/relay/convex/index.d.ts +39 -0
- package/dist/remote/relay/convex/index.d.ts.map +1 -0
- package/dist/remote/relay/convex/index.js +36 -0
- package/dist/remote/relay/convex/index.js.map +1 -0
- package/dist/remote/relay/convex/relay.d.ts +339 -0
- package/dist/remote/relay/convex/relay.d.ts.map +1 -0
- package/dist/remote/relay/convex/relay.js +1086 -0
- package/dist/remote/relay/convex/relay.js.map +1 -0
- package/dist/remote/relay/convex/types.d.ts +111 -0
- package/dist/remote/relay/convex/types.d.ts.map +1 -0
- package/dist/remote/relay/convex/types.js +19 -0
- package/dist/remote/relay/convex/types.js.map +1 -0
- package/dist/remote/relay/index.d.ts +34 -0
- package/dist/remote/relay/index.d.ts.map +1 -0
- package/dist/remote/relay/index.js +28 -0
- package/dist/remote/relay/index.js.map +1 -0
- package/dist/remote/relay/mock/adapter.d.ts +237 -0
- package/dist/remote/relay/mock/adapter.d.ts.map +1 -0
- package/dist/remote/relay/mock/adapter.js +939 -0
- package/dist/remote/relay/mock/adapter.js.map +1 -0
- package/dist/remote/relay/mock/index.d.ts +10 -0
- package/dist/remote/relay/mock/index.d.ts.map +1 -0
- package/dist/remote/relay/mock/index.js +6 -0
- package/dist/remote/relay/mock/index.js.map +1 -0
- package/dist/remote/relay/types.d.ts +756 -0
- package/dist/remote/relay/types.d.ts.map +1 -0
- package/dist/remote/relay/types.js +11 -0
- package/dist/remote/relay/types.js.map +1 -0
- package/dist/safety/core.d.ts +108 -0
- package/dist/safety/core.d.ts.map +1 -0
- package/dist/safety/core.js +299 -0
- package/dist/safety/core.js.map +1 -0
- package/dist/safety/fingerprint.d.ts +277 -0
- package/dist/safety/fingerprint.d.ts.map +1 -0
- package/dist/safety/fingerprint.js +339 -0
- package/dist/safety/fingerprint.js.map +1 -0
- package/dist/safety/index.d.ts +141 -0
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/index.js +230 -0
- package/dist/safety/index.js.map +1 -0
- package/dist/safety/protobuf.d.ts +34 -0
- package/dist/safety/protobuf.d.ts.map +1 -0
- package/dist/safety/protobuf.js +142 -0
- package/dist/safety/protobuf.js.map +1 -0
- package/dist/safety/url.d.ts +133 -0
- package/dist/safety/url.d.ts.map +1 -0
- package/dist/safety/url.js +242 -0
- package/dist/safety/url.js.map +1 -0
- package/dist/sealed-sender/index.d.ts +7 -0
- package/dist/sealed-sender/index.d.ts.map +1 -0
- package/dist/sealed-sender/index.js +6 -0
- package/dist/sealed-sender/index.js.map +1 -0
- package/dist/server-clock.d.ts +10 -0
- package/dist/server-clock.d.ts.map +1 -0
- package/dist/server-clock.js +27 -0
- package/dist/server-clock.js.map +1 -0
- package/dist/types/address.d.ts +171 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/address.js +241 -0
- package/dist/types/address.js.map +1 -0
- package/dist/types/api.d.ts +1222 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +5 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/errors.d.ts +772 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +937 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +33 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/messages.d.ts +257 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +96 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/protocol-config.d.ts +337 -0
- package/dist/types/protocol-config.d.ts.map +1 -0
- package/dist/types/protocol-config.js +178 -0
- package/dist/types/protocol-config.js.map +1 -0
- package/dist/types/protocol-constants.d.ts +122 -0
- package/dist/types/protocol-constants.d.ts.map +1 -0
- package/dist/types/protocol-constants.js +115 -0
- package/dist/types/protocol-constants.js.map +1 -0
- package/dist/types/session.d.ts +721 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +340 -0
- package/dist/types/session.js.map +1 -0
- package/dist/types/trust.d.ts +168 -0
- package/dist/types/trust.d.ts.map +1 -0
- package/dist/types/trust.js +84 -0
- package/dist/types/trust.js.map +1 -0
- package/dist/types/utils.d.ts +93 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +89 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/username/index.d.ts +12 -0
- package/dist/username/index.d.ts.map +1 -0
- package/dist/username/index.js +11 -0
- package/dist/username/index.js.map +1 -0
- package/dist/username/link.d.ts +52 -0
- package/dist/username/link.d.ts.map +1 -0
- package/dist/username/link.js +87 -0
- package/dist/username/link.js.map +1 -0
- package/dist/utils/binary-transfer.d.ts +18 -0
- package/dist/utils/binary-transfer.d.ts.map +1 -0
- package/dist/utils/binary-transfer.js +27 -0
- package/dist/utils/binary-transfer.js.map +1 -0
- package/dist/utils/errors.d.ts +9 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +15 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/retry.d.ts +59 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +136 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/versions.d.ts +62 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +78 -0
- package/dist/versions.js.map +1 -0
- package/dist/zk/credentials.d.ts +10 -0
- package/dist/zk/credentials.d.ts.map +1 -0
- package/dist/zk/credentials.js +9 -0
- package/dist/zk/credentials.js.map +1 -0
- package/dist/zk/groups.d.ts +12 -0
- package/dist/zk/groups.d.ts.map +1 -0
- package/dist/zk/groups.js +11 -0
- package/dist/zk/groups.js.map +1 -0
- package/docs/ASSURANCE.md +102 -0
- package/docs/CLIENT_COMPOSITION.md +189 -0
- package/docs/DOCUMENTATION_STANDARDS.md +107 -0
- package/docs/E2EE.md +35 -0
- package/docs/ERROR_HANDLING.md +396 -0
- package/docs/GETTING_STARTED.md +714 -0
- package/docs/INTERFACES.md +187 -0
- package/docs/PACKAGE_SURFACE.md +235 -0
- package/docs/PROTOCOL_POLICY.md +109 -0
- package/docs/RECIPES.md +389 -0
- package/docs/SECURITY.md +199 -0
- package/docs/api/README.md +471 -0
- package/docs/api/classes/EncryptionError.md +112 -0
- package/docs/api/classes/EndorsementManager.md +307 -0
- package/docs/api/classes/SealedSenderAuthError.md +127 -0
- package/docs/api/classes/ServerDerivedKeyPair.md +68 -0
- package/docs/api/classes/ServerDerivedPublicKey.md +33 -0
- package/docs/api/classes/ServerRootKeyPair.md +94 -0
- package/docs/api/classes/ServerRootPublicKey.md +72 -0
- package/docs/api/classes/SignalBlockingManager.md +106 -0
- package/docs/api/classes/SignalProtocolClient.md +2651 -0
- package/docs/api/classes/VerificationFailure.md +25 -0
- package/docs/api/enumerations/ContentHint.md +63 -0
- package/docs/api/enumerations/EncryptionErrorCode.md +488 -0
- package/docs/api/enumerations/IdentityKeyChange.md +65 -0
- package/docs/api/enumerations/MessageType.md +29 -0
- package/docs/api/enumerations/TrustDirection.md +33 -0
- package/docs/api/enumerations/TypingAction.md +31 -0
- package/docs/api/functions/createDefaultSignalContentAdapter.md +13 -0
- package/docs/api/functions/createDefaultSignalLogger.md +36 -0
- package/docs/api/functions/createGroupId.md +32 -0
- package/docs/api/functions/createSignalProtocolClient.md +36 -0
- package/docs/api/functions/createSignalProtocolClientConfig.md +24 -0
- package/docs/api/functions/extractGroupId.md +32 -0
- package/docs/api/functions/formatVersion.md +25 -0
- package/docs/api/functions/isCompatible.md +31 -0
- package/docs/api/functions/isGroupId.md +37 -0
- package/docs/api/functions/isSealedSenderAuthError.md +25 -0
- package/docs/api/functions/parseVersion.md +29 -0
- package/docs/api/functions/resolveSPQRLimits.md +21 -0
- package/docs/api/functions/resolveSignalLogger.md +42 -0
- package/docs/api/interfaces/AccountIdentityProvisioning.md +43 -0
- package/docs/api/interfaces/AccountIdentityRotation.md +69 -0
- package/docs/api/interfaces/AttachmentTransferOptions.md +49 -0
- package/docs/api/interfaces/BlockedRecipientEntry.md +25 -0
- package/docs/api/interfaces/BlockedRecipientsSyncInput.md +27 -0
- package/docs/api/interfaces/ConfigurationSyncInput.md +19 -0
- package/docs/api/interfaces/CredentialPublicKey.md +25 -0
- package/docs/api/interfaces/DataMessageInput.md +21 -0
- package/docs/api/interfaces/DecryptedEnvelope.md +95 -0
- package/docs/api/interfaces/DecryptedGroup.md +86 -0
- package/docs/api/interfaces/DeviceInfo.md +79 -0
- package/docs/api/interfaces/DeviceRecord.md +87 -0
- package/docs/api/interfaces/DeviceRegistration.md +27 -0
- package/docs/api/interfaces/DoubleRatchetConfig.md +36 -0
- package/docs/api/interfaces/EcOneTimePreKey.md +27 -0
- package/docs/api/interfaces/EcSignedPreKey.md +39 -0
- package/docs/api/interfaces/EcSignedPreKeyUpload.md +50 -0
- package/docs/api/interfaces/EncryptionErrorContext.md +51 -0
- package/docs/api/interfaces/Envelope.md +154 -0
- package/docs/api/interfaces/ForceKeyResetResult.md +37 -0
- package/docs/api/interfaces/GroupAuthorization.md +23 -0
- package/docs/api/interfaces/GroupChangeEntry.md +42 -0
- package/docs/api/interfaces/GroupMemberDevice.md +26 -0
- package/docs/api/interfaces/IEcOneTimePreKeyStore.md +86 -0
- package/docs/api/interfaces/IEcSignedPreKeyStore.md +132 -0
- package/docs/api/interfaces/IGroupServer.md +120 -0
- package/docs/api/interfaces/IGroupStateStore.md +128 -0
- package/docs/api/interfaces/IIdentityKeyStore.md +312 -0
- package/docs/api/interfaces/IKemPreKeyStore.md +144 -0
- package/docs/api/interfaces/IKyberLastResortPreKeyStore.md +111 -0
- package/docs/api/interfaces/ILogger.md +117 -0
- package/docs/api/interfaces/IProtocolStore.md +1033 -0
- package/docs/api/interfaces/ISenderKeyStore.md +417 -0
- package/docs/api/interfaces/ISesameStore.md +249 -0
- package/docs/api/interfaces/ISessionStore.md +178 -0
- package/docs/api/interfaces/ISignalLocalSecretVault.md +71 -0
- package/docs/api/interfaces/ISignalLocalStore.md +2053 -0
- package/docs/api/interfaces/ISignalProtocolClient.md +1183 -0
- package/docs/api/interfaces/ISignalProtocolManager.md +272 -0
- package/docs/api/interfaces/ISignalRelayServer.md +1329 -0
- package/docs/api/interfaces/IdentityKeyPair.md +49 -0
- package/docs/api/interfaces/IncomingEnvelope.md +91 -0
- package/docs/api/interfaces/InspectedSignalContent.md +43 -0
- package/docs/api/interfaces/KDFChain.md +31 -0
- package/docs/api/interfaces/KemLastResortPreKeyUpload.md +50 -0
- package/docs/api/interfaces/KeyPair.md +23 -0
- package/docs/api/interfaces/KyberPreKey.md +42 -0
- package/docs/api/interfaces/MLKEMBraidAgentState.md +191 -0
- package/docs/api/interfaces/MLKEMBraidMessage.md +49 -0
- package/docs/api/interfaces/MediaAttachmentDeleteSyncInput.md +31 -0
- package/docs/api/interfaces/MessageHeader.md +49 -0
- package/docs/api/interfaces/MessageRecord.md +86 -0
- package/docs/api/interfaces/ParsedReceiptContent.md +19 -0
- package/docs/api/interfaces/ParsedTypingContent.md +19 -0
- package/docs/api/interfaces/PreKeyMaintenanceStore.md +87 -0
- package/docs/api/interfaces/PreKeyMessage.md +159 -0
- package/docs/api/interfaces/PreKeyStatusResult.md +21 -0
- package/docs/api/interfaces/PreKeyUpload.md +42 -0
- package/docs/api/interfaces/ProcessEnvelopeOptions.md +72 -0
- package/docs/api/interfaces/ProtocolAddress.md +38 -0
- package/docs/api/interfaces/ProtocolStrategyConfig.md +91 -0
- package/docs/api/interfaces/RatchetMessage.md +96 -0
- package/docs/api/interfaces/ReadSyncEntryInput.md +19 -0
- package/docs/api/interfaces/ReceiverChain.md +43 -0
- package/docs/api/interfaces/RecipientUsernameSyncInput.md +31 -0
- package/docs/api/interfaces/RelayPreKeyBundle.md +254 -0
- package/docs/api/interfaces/RemoteObjectDownload.md +33 -0
- package/docs/api/interfaces/RemoteObjectUpload.md +49 -0
- package/docs/api/interfaces/ResolvedSPQRInfoStrings.md +27 -0
- package/docs/api/interfaces/ResolvedSPQRLimits.md +37 -0
- package/docs/api/interfaces/RetryRequest.md +80 -0
- package/docs/api/interfaces/SCKAState.md +65 -0
- package/docs/api/interfaces/SPQRLimits.md +40 -0
- package/docs/api/interfaces/SPQRState.md +191 -0
- package/docs/api/interfaces/SafetyNumber.md +60 -0
- package/docs/api/interfaces/SafetyNumberConfirmation.md +46 -0
- package/docs/api/interfaces/SealedSenderConfig.md +70 -0
- package/docs/api/interfaces/SendOptions.md +191 -0
- package/docs/api/interfaces/SendResult.md +93 -0
- package/docs/api/interfaces/SenderKeyDistributionMessage.md +43 -0
- package/docs/api/interfaces/SenderKeyState.md +76 -0
- package/docs/api/interfaces/SenderKeysConfig.md +65 -0
- package/docs/api/interfaces/SentSyncTranscriptInput.md +31 -0
- package/docs/api/interfaces/ServiceId.md +19 -0
- package/docs/api/interfaces/SesameMessage.md +84 -0
- package/docs/api/interfaces/SesameStats.md +57 -0
- package/docs/api/interfaces/SessionHealthResult.md +120 -0
- package/docs/api/interfaces/SessionRecord.md +80 -0
- package/docs/api/interfaces/SessionRecordMetadata.md +109 -0
- package/docs/api/interfaces/SessionState.md +368 -0
- package/docs/api/interfaces/SessionTrustCommit.md +58 -0
- package/docs/api/interfaces/SignalBlockingHooks.md +44 -0
- package/docs/api/interfaces/SignalBlockingManagerOptions.md +31 -0
- package/docs/api/interfaces/SignalBlockingMirror.md +30 -0
- package/docs/api/interfaces/SignalBlockingStore.md +83 -0
- package/docs/api/interfaces/SignalContentAdapter.md +325 -0
- package/docs/api/interfaces/SignalProtocolClientAdapterConfig.md +44 -0
- package/docs/api/interfaces/SignalProtocolClientCompositionOptions.md +693 -0
- package/docs/api/interfaces/SignalProtocolClientConfig.md +839 -0
- package/docs/api/interfaces/SignalProtocolClientDeleteLocalAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientHooks.md +506 -0
- package/docs/api/interfaces/SignalProtocolClientIdentityConfig.md +35 -0
- package/docs/api/interfaces/SignalProtocolClientLoadLocalAttachmentInput.md +187 -0
- package/docs/api/interfaces/SignalProtocolClientLoadedLocalAttachment.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMedia.md +83 -0
- package/docs/api/interfaces/SignalProtocolClientMediaCompletedResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaConfig.md +157 -0
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadCompletedResult.md +37 -0
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadNotNeededResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaFailedResult.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMediaOperationOptions.md +53 -0
- package/docs/api/interfaces/SignalProtocolClientMediaPendingResult.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMediaProcessResult.md +43 -0
- package/docs/api/interfaces/SignalProtocolClientMediaSkippedResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaUploadCompletedResult.md +31 -0
- package/docs/api/interfaces/SignalProtocolClientProcessPendingMediaOptions.md +87 -0
- package/docs/api/interfaces/SignalProtocolClientSaveDownloadedAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientSaveUploadedAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientSyncDeleteInput.md +19 -0
- package/docs/api/interfaces/SignalProtocolConfig.md +50 -0
- package/docs/api/interfaces/SignalRemoteObjectStore.md +88 -0
- package/docs/api/interfaces/SkippedSenderMessageKey.md +26 -0
- package/docs/api/interfaces/TaskNotificationAckSyncInput.md +31 -0
- package/docs/api/interfaces/TripleRatchetState.md +64 -0
- package/docs/api/interfaces/UserRecord.md +71 -0
- package/docs/api/interfaces/UsernameStateSyncInput.md +19 -0
- package/docs/api/interfaces/VerificationStateSyncInput.md +31 -0
- package/docs/api/interfaces/VersionNegotiationState.md +84 -0
- package/docs/api/interfaces/ViewOnceOpenSyncInput.md +19 -0
- package/docs/api/namespaces/ProtocolAddress/README.md +33 -0
- package/docs/api/namespaces/ProtocolAddress/functions/create.md +41 -0
- package/docs/api/namespaces/ProtocolAddress/functions/equals.md +39 -0
- package/docs/api/namespaces/ProtocolAddress/functions/fromStorageKey.md +36 -0
- package/docs/api/namespaces/ProtocolAddress/functions/isUser.md +39 -0
- package/docs/api/namespaces/ProtocolAddress/functions/isValid.md +34 -0
- package/docs/api/namespaces/ProtocolAddress/functions/parse.md +41 -0
- package/docs/api/namespaces/ProtocolAddress/functions/toStorageKey.md +38 -0
- package/docs/api/namespaces/ProtocolAddress/functions/toString.md +34 -0
- package/docs/api/namespaces/SessionRecord/README.md +30 -0
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrent.md +40 -0
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrentState.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/create.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/deserialize.md +29 -0
- package/docs/api/namespaces/SessionRecord/functions/findSession.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/getAllSessions.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/getArchivedCount.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/hasCurrentSession.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/hasUsableSenderChain.md +36 -0
- package/docs/api/namespaces/SessionRecord/functions/promoteSession.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/serialize.md +28 -0
- package/docs/api/namespaces/SessionRecord/variables/MAX_ARCHIVED_SESSIONS.md +14 -0
- package/docs/api/namespaces/SessionState/README.md +15 -0
- package/docs/api/namespaces/SessionState/functions/getSessionId.md +32 -0
- package/docs/api/namespaces/blocking/README.md +43 -0
- package/docs/api/namespaces/encoding/README.md +33 -0
- package/docs/api/namespaces/encoding/functions/base64ToUrlSafe.md +28 -0
- package/docs/api/namespaces/encoding/functions/bytesToBase64.md +21 -0
- package/docs/api/namespaces/encoding/functions/bytesToString.md +21 -0
- package/docs/api/namespaces/encoding/functions/bytesToUrlSafeBase64.md +33 -0
- package/docs/api/namespaces/encoding/functions/concatBytes.md +21 -0
- package/docs/api/namespaces/encoding/functions/stringToBytes.md +21 -0
- package/docs/api/namespaces/encoding/functions/urlSafeToBase64.md +27 -0
- package/docs/api/namespaces/keys/README.md +126 -0
- package/docs/api/namespaces/keys/functions/acceptContactIdentityRotation.md +33 -0
- package/docs/api/namespaces/keys/functions/assertIdentityCommitment.md +25 -0
- package/docs/api/namespaces/keys/functions/compositeIdentitiesEqual.md +23 -0
- package/docs/api/namespaces/keys/functions/createCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/createPreKeySignatureContext.md +31 -0
- package/docs/api/namespaces/keys/functions/createUnverifiedContactIdentityRecord.md +23 -0
- package/docs/api/namespaces/keys/functions/decodeCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/deriveIdentityCommitment.md +19 -0
- package/docs/api/namespaces/keys/functions/encodeCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/evaluateContactIdentityCandidate.md +27 -0
- package/docs/api/namespaces/keys/functions/generateEcOneTimePreKeys.md +37 -0
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKey.md +39 -0
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKeyId.md +21 -0
- package/docs/api/namespaces/keys/functions/generateIdentityKeyPair.md +24 -0
- package/docs/api/namespaces/keys/functions/generateKemOneTimePreKeys.md +47 -0
- package/docs/api/namespaces/keys/functions/generateKyberLastResortPreKey.md +37 -0
- package/docs/api/namespaces/keys/functions/generateRegistrationId.md +13 -0
- package/docs/api/namespaces/keys/functions/signMlKem1024PreKey.md +29 -0
- package/docs/api/namespaces/keys/functions/signPreKey.md +31 -0
- package/docs/api/namespaces/keys/functions/validateContactIdentityRecord.md +19 -0
- package/docs/api/namespaces/keys/functions/verifyContactIdentityRecord.md +31 -0
- package/docs/api/namespaces/keys/functions/verifyMlKem1024PreKey.md +33 -0
- package/docs/api/namespaces/keys/functions/verifyPreKeySignature.md +35 -0
- package/docs/api/namespaces/keys/interfaces/CompositeIdentityV1.md +33 -0
- package/docs/api/namespaces/keys/interfaces/ContactIdentityRecord.md +53 -0
- package/docs/api/namespaces/keys/interfaces/KemOneTimePreKey.md +43 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityCandidateStatus.md +9 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityTrustState.md +9 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityType.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_ED25519_TAG.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_LENGTH.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_VERSION.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_X25519_TAG.md +9 -0
- package/docs/api/namespaces/keys/variables/IDENTITY_COMMITMENT_V1_DOMAIN.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_ML_KEM_1024.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_X25519.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_SIGNATURE_V1_DOMAIN.md +9 -0
- package/docs/api/namespaces/media/README.md +105 -0
- package/docs/api/namespaces/media/classes/MediaAttachmentError.md +57 -0
- package/docs/api/namespaces/media/functions/createByteRangeMediaAttachmentTransfer.md +19 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentDeliveryId.md +29 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentId.md +19 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentMessage.md +25 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentPointer.md +19 -0
- package/docs/api/namespaces/media/functions/createTusMediaAttachmentTransfer.md +19 -0
- package/docs/api/namespaces/media/functions/deleteMediaAttachment.md +23 -0
- package/docs/api/namespaces/media/functions/executeMediaAttachmentJob.md +23 -0
- package/docs/api/namespaces/media/functions/isMediaAttachmentFlagSet.md +19 -0
- package/docs/api/namespaces/media/functions/parseMediaAttachmentMessage.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanup.md +23 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanupJobs.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentDeleteSync.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentDownloadJob.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentOpen.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentProcessing.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentUploadJob.md +19 -0
- package/docs/api/namespaces/media/functions/prepareMediaAttachmentUpload.md +30 -0
- package/docs/api/namespaces/media/functions/resolveMediaAttachment.md +30 -0
- package/docs/api/namespaces/media/functions/serializeMediaAttachmentMessage.md +25 -0
- package/docs/api/namespaces/media/functions/validateMediaAttachmentPolicy.md +23 -0
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentPartialStore.md +68 -0
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentTransferOptions.md +91 -0
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentOptions.md +25 -0
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentResult.md +19 -0
- package/docs/api/namespaces/media/interfaces/ExecuteMediaAttachmentJobOptions.md +157 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentBackgroundJob.md +85 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentCleanupPlan.md +37 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentJobExecutionResult.md +55 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentMessage.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentOpenDecision.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPointer.md +133 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPolicy.md +67 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProcessingPlan.md +73 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProgress.md +69 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentResumeState.md +37 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentRetryOptions.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransfer.md +51 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferCheckpoint.md +69 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferOptions.md +67 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadJobData.md +19 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadResponse.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentCleanupJobsInput.md +61 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDeleteSyncInput.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDownloadJobInput.md +161 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentOpenInput.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentProcessingInput.md +83 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentUploadJobInput.md +147 -0
- package/docs/api/namespaces/media/interfaces/PrepareMediaAttachmentUploadOptions.md +144 -0
- package/docs/api/namespaces/media/interfaces/ResolveMediaAttachmentOptions.md +55 -0
- package/docs/api/namespaces/media/interfaces/ResolvedMediaAttachment.md +109 -0
- package/docs/api/namespaces/media/interfaces/TusMediaAttachmentTransferOptions.md +85 -0
- package/docs/api/namespaces/media/type-aliases/CreateMediaAttachmentPointerInput.md +15 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCheckpointCallback.md +19 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCleanupReason.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentErrorCode.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentFlag.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobExecutionStatus.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobOperation.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobPriority.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSkipReason.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSource.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentKnownIds.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentMessageType.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentProgressCallback.md +19 -0
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_DEFAULTS.md +47 -0
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_PRESETS.md +95 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentCleanupReason.md +27 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentErrorCode.md +75 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentFlag.md +23 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobExecutionStatus.md +19 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobOperation.md +31 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobPriority.md +23 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobSource.md +51 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentMessageType.md +15 -0
- package/docs/api/namespaces/media/variables/downloadMediaAttachment.md +30 -0
- package/docs/api/namespaces/safety/README.md +61 -0
- package/docs/api/namespaces/safety/classes/DisplayableFingerprint.md +108 -0
- package/docs/api/namespaces/safety/classes/Fingerprint.md +104 -0
- package/docs/api/namespaces/safety/classes/ScannableFingerprint.md +209 -0
- package/docs/api/namespaces/safety/functions/base64ToBytes.md +21 -0
- package/docs/api/namespaces/safety/functions/clearFingerprintCache.md +15 -0
- package/docs/api/namespaces/safety/functions/compareSafetyNumbers.md +25 -0
- package/docs/api/namespaces/safety/functions/createFingerprintData.md +60 -0
- package/docs/api/namespaces/safety/functions/extractQrData.md +34 -0
- package/docs/api/namespaces/safety/functions/generateCompositeSafetyNumber.md +39 -0
- package/docs/api/namespaces/safety/functions/generateEmojiFingerprint.md +24 -0
- package/docs/api/namespaces/safety/functions/generateSingleKeyReferenceSafetyNumber.md +51 -0
- package/docs/api/namespaces/safety/functions/generateVerifySchemeUrl.md +32 -0
- package/docs/api/namespaces/safety/functions/generateVerifyUrl.md +49 -0
- package/docs/api/namespaces/safety/functions/isValidSafetyNumber.md +21 -0
- package/docs/api/namespaces/safety/functions/isVerifyUrl.md +45 -0
- package/docs/api/namespaces/safety/functions/parseVerifyUrl.md +31 -0
- package/docs/api/namespaces/safety/interfaces/FingerprintData.md +52 -0
- package/docs/api/namespaces/safety/interfaces/SafetyNumber.md +49 -0
- package/docs/api/namespaces/safety/interfaces/VerifyLinkConfig.md +28 -0
- package/docs/api/namespaces/safety/interfaces/VerifyUrlParams.md +49 -0
- package/docs/api/namespaces/safety/type-aliases/CompareResult.md +21 -0
- package/docs/api/namespaces/safety/variables/DEFAULT_VERIFY_LINK_CONFIG.md +12 -0
- package/docs/api/namespaces/safety/variables/FINGERPRINT_ITERATIONS.md +12 -0
- package/docs/api/namespaces/safety/variables/FINGERPRINT_VERSION.md +12 -0
- package/docs/api/namespaces/safety/variables/VERIFY_BASE_URL.md +11 -0
- package/docs/api/namespaces/safety/variables/VERIFY_SCHEME_URL.md +11 -0
- package/docs/api/type-aliases/Base64.md +20 -0
- package/docs/api/type-aliases/BraidPolicy.md +11 -0
- package/docs/api/type-aliases/Bytes.md +20 -0
- package/docs/api/type-aliases/Ciphertext.md +21 -0
- package/docs/api/type-aliases/DeviceType.md +11 -0
- package/docs/api/type-aliases/DownloadedAttachment.md +11 -0
- package/docs/api/type-aliases/GroupId.md +27 -0
- package/docs/api/type-aliases/Hex.md +20 -0
- package/docs/api/type-aliases/HookName.md +11 -0
- package/docs/api/type-aliases/PostQuantumPolicy.md +11 -0
- package/docs/api/type-aliases/PreparedAttachmentUpload.md +14 -0
- package/docs/api/type-aliases/PrivateKey.md +22 -0
- package/docs/api/type-aliases/ProgressCallback.md +45 -0
- package/docs/api/type-aliases/PublicKey.md +22 -0
- package/docs/api/type-aliases/RemoteObjectCompleteUploadRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectDeleteRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectDownloadRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectUploadRequest.md +42 -0
- package/docs/api/type-aliases/SCKAMode.md +11 -0
- package/docs/api/type-aliases/SealedSenderAuth.md +15 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaOperationResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadResult.md +9 -0
- package/docs/api/type-aliases/Signature.md +21 -0
- package/docs/api/type-aliases/Unsubscribe.md +15 -0
- package/docs/api/variables/BraidPolicy.md +21 -0
- package/docs/api/variables/DEFAULT_DEVICE_ID.md +12 -0
- package/docs/api/variables/DOUBLE_RATCHET_SPEC.md +11 -0
- package/docs/api/variables/GROUP_V2_PREFIX.md +11 -0
- package/docs/api/variables/KEY_REFRESH_INTERVAL_MS_DEFAULT.md +11 -0
- package/docs/api/variables/MAX_MESSAGE_KEYS.md +14 -0
- package/docs/api/variables/MAX_PREKEY_AGE_MS_DEFAULT.md +11 -0
- package/docs/api/variables/MAX_RECEIVER_CHAINS.md +14 -0
- package/docs/api/variables/MAX_REGISTRATION_ID.md +16 -0
- package/docs/api/variables/MAX_SKIP.md +11 -0
- package/docs/api/variables/MESSAGE_FORMAT.md +11 -0
- package/docs/api/variables/MIN_REGISTRATION_ID.md +16 -0
- package/docs/api/variables/ML_KEM_BRAID_SPEC.md +11 -0
- package/docs/api/variables/ONE_TIME_PREKEY_BATCH_SIZE.md +21 -0
- package/docs/api/variables/PQXDH_SPEC.md +11 -0
- package/docs/api/variables/PostQuantumPolicy.md +21 -0
- package/docs/api/variables/SENDER_KEY_FORMAT.md +11 -0
- package/docs/api/variables/SENDER_KEY_SPEC.md +11 -0
- package/docs/api/variables/SESAME_SPEC.md +11 -0
- package/docs/api/variables/SESSION_FORMAT.md +11 -0
- package/docs/api/variables/SPQR_LIMITS_DEFAULTS.md +11 -0
- package/docs/api/variables/X3DH_SPEC.md +9 -0
- package/docs/api/variables/defaultSignalLogger.md +32 -0
- package/encoding/README.md +32 -0
- package/files/README.md +37 -0
- package/groups/README.md +42 -0
- package/hooks/README.md +40 -0
- package/keys/README.md +121 -0
- package/local/store/README.md +120 -0
- package/local/store/expo/README.md +73 -0
- package/local/store/mock/README.md +27 -0
- package/local/store/node/README.md +35 -0
- package/local/store/react-native/README.md +39 -0
- package/local/store/web/README.md +65 -0
- package/local/vault/README.md +32 -0
- package/media/README.md +73 -0
- package/package.json +436 -0
- package/profile/README.md +44 -0
- package/remote/README.md +219 -0
- package/remote/object-store/README.md +45 -0
- package/remote/object-store/convex-r2/README.md +85 -0
- package/remote/object-store/s3/README.md +35 -0
- package/remote/relay/README.md +38 -0
- package/remote/relay/convex/README.md +54 -0
- package/remote/relay/mock/README.md +32 -0
- package/safety/README.md +42 -0
- package/sealed-sender/README.md +32 -0
- package/types/README.md +36 -0
- package/username/README.md +37 -0
- package/utils/README.md +37 -0
- package/zk/README.md +36 -0
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPQR (Sparse Post-Quantum Ratchet) Operations
|
|
3
|
+
*
|
|
4
|
+
* @module spqr/spqr
|
|
5
|
+
*
|
|
6
|
+
* Signal Protocol Section 5 & 6 implementation for Triple Ratchet.
|
|
7
|
+
* Provides post-quantum security through ML-KEM-768 (CRYSTALS-Kyber)
|
|
8
|
+
* key encapsulation mechanism, protecting against "harvest now, decrypt later"
|
|
9
|
+
* quantum computer attacks.
|
|
10
|
+
*
|
|
11
|
+
* ## Tiered ML-KEM Security Model
|
|
12
|
+
*
|
|
13
|
+
* Signal uses different ML-KEM variants for different protocols:
|
|
14
|
+
*
|
|
15
|
+
* | Protocol | ML-KEM Variant | NIST Level | Usage |
|
|
16
|
+
* |----------|----------------|------------|----------------------|
|
|
17
|
+
* | PQXDH | ML-KEM-1024 | 5 (256-bit)| Initial key exchange |
|
|
18
|
+
* | SPQR | ML-KEM-768 | 3 (192-bit)| Continuous ratchet |
|
|
19
|
+
*
|
|
20
|
+
* **Rationale for ML-KEM-768 in SPQR:**
|
|
21
|
+
* - Continuous ratchet sends key material every ~50 messages
|
|
22
|
+
* - ML-KEM-768: 1,088 bytes/ratchet vs ML-KEM-1024: 1,568 bytes
|
|
23
|
+
* - Hybrid mode (EC + PQ) provides defense-in-depth anyway
|
|
24
|
+
* - NIST recommends Level 3 for general-purpose use
|
|
25
|
+
*
|
|
26
|
+
* ## Overview
|
|
27
|
+
*
|
|
28
|
+
* SPQR runs in parallel with the EC Double Ratchet, providing a second layer
|
|
29
|
+
* of key agreement using post-quantum cryptography. The message keys from both
|
|
30
|
+
* ratchets are combined via KDF_HYBRID to produce the final encryption keys.
|
|
31
|
+
*
|
|
32
|
+
* ## Architecture
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
* ┌────────────────────────────────────────────────────────────┐
|
|
36
|
+
* │ Triple Ratchet │
|
|
37
|
+
* ├─────────────────────────┬──────────────────────────────────┤
|
|
38
|
+
* │ EC Double Ratchet │ SPQR (This Module) │
|
|
39
|
+
* │ ┌─────────────────┐ │ ┌─────────────────────────┐ │
|
|
40
|
+
* │ │ X25519 DH │ │ │ ML-KEM-768 (Kyber) │ │
|
|
41
|
+
* │ │ Ratchet Keys │ │ │ Encapsulation │ │
|
|
42
|
+
* │ └────────┬────────┘ │ └───────────┬─────────────┘ │
|
|
43
|
+
* │ │ │ │ │
|
|
44
|
+
* │ v │ v │
|
|
45
|
+
* │ ┌─────────────────┐ │ ┌─────────────────────────┐ │
|
|
46
|
+
* │ │ EC KDF Chain │ │ │ SPQR KDF Chain │ │
|
|
47
|
+
* │ │ (per DH step) │ │ │ (per epoch) │ │
|
|
48
|
+
* │ └────────┬────────┘ │ └───────────┬─────────────┘ │
|
|
49
|
+
* │ │ │ │ │
|
|
50
|
+
* │ v │ v │
|
|
51
|
+
* │ ┌─────────────────┐ │ ┌─────────────────────────┐ │
|
|
52
|
+
* │ │ EC Message Key │────┼───>│ KDF_HYBRID │ │
|
|
53
|
+
* │ └─────────────────┘ │ │ (combine EC + PQ keys) │ │
|
|
54
|
+
* │ │ └───────────┬─────────────┘ │
|
|
55
|
+
* │ │ │ │
|
|
56
|
+
* │ │ v │
|
|
57
|
+
* │ │ ┌─────────────────────────┐ │
|
|
58
|
+
* │ │ │ Final Message Key │ │
|
|
59
|
+
* │ │ └─────────────────────────┘ │
|
|
60
|
+
* └─────────────────────────┴──────────────────────────────────┘
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* ## Key Concepts
|
|
64
|
+
*
|
|
65
|
+
* - **Epoch**: Incremented with each DH ratchet step (synchronized)
|
|
66
|
+
* - **SCKA State**: Symmetric Continuous Key Agreement state (ML-KEM keys)
|
|
67
|
+
* - **KDF Chains**: Per-epoch send/receive chains for message keys
|
|
68
|
+
* - **Output Reordering**: Alice uses (CKs, CKr), Bob uses (CKr, CKs)
|
|
69
|
+
*
|
|
70
|
+
* ## HKDF Info Strings (Profile)
|
|
71
|
+
*
|
|
72
|
+
* - `'Signal PQ Ratchet V1 Chain Start'` - Initial chain setup (96 bytes, note double space)
|
|
73
|
+
* - `'Signal PQ Ratchet V1 Chain Add Epoch'` - Epoch advancement (96 bytes)
|
|
74
|
+
* - `'Signal PQ Ratchet V1 Chain Next'` - Per-message advancement (64 bytes)
|
|
75
|
+
*
|
|
76
|
+
* ## Security Properties
|
|
77
|
+
*
|
|
78
|
+
* - **Post-Quantum Contribution**: standardized ML-KEM-768 feeds each eligible
|
|
79
|
+
* epoch; the end-to-end claim remains conditional on the full protocol
|
|
80
|
+
* - **Forward Secrecy**: Old state is pruned and owned byte buffers are cleared
|
|
81
|
+
* on a best-effort basis; JavaScript cannot guarantee physical erasure
|
|
82
|
+
* - **Hybrid intent**: a later EC break alone should not recover epochs whose
|
|
83
|
+
* ML-KEM contribution and surrounding protocol assumptions remain secure
|
|
84
|
+
* - **Sparse Ratcheting**: Only ratchets on DH steps (reduces overhead)
|
|
85
|
+
*
|
|
86
|
+
* ## Specification References
|
|
87
|
+
*
|
|
88
|
+
* @see https://signal.org/blog/spqr/ - Signal SPQR specification
|
|
89
|
+
* @see https://csrc.nist.gov/pubs/fips/203/final - NIST FIPS 203 (ML-KEM)
|
|
90
|
+
*
|
|
91
|
+
* @example Initialize SPQR state
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const spqrState = await initializeSPQRState(
|
|
94
|
+
* initialRootKey, // From PQXDH key agreement
|
|
95
|
+
* 'A2B', // Alice is initiator
|
|
96
|
+
* ourKyberPrivKey, // Our ML-KEM-768 private key
|
|
97
|
+
* theirKyberPubKey // Their ML-KEM-768 public key
|
|
98
|
+
* );
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
import { base64ToBytes, bytesToBase64,
|
|
102
|
+
// ML-KEM-768 functions (for SPQR continuous ratchet)
|
|
103
|
+
generateKyber768KeyPair, kyber768Decapsulate, kyber768Encapsulate,
|
|
104
|
+
// SPQR-specific KDF functions (profile)
|
|
105
|
+
kdfSpqrInit, kdfSpqrEpoch, kdfChainKeySPQR, secureZeroBytes,
|
|
106
|
+
// Info string resolution
|
|
107
|
+
resolveSPQRInfoStrings, } from '../../crypto/index.js';
|
|
108
|
+
import { defaultSignalLogger } from '../../../logger.js';
|
|
109
|
+
// SPQR limits configuration (profile protocol defaults)
|
|
110
|
+
import { SPQR_LIMITS_DEFAULTS } from '../../../types/protocol-config.js';
|
|
111
|
+
import { EncryptionError, EncryptionErrorCode } from '../../../types/errors.js';
|
|
112
|
+
import { asBase64 } from '../../../types/utils.js';
|
|
113
|
+
import { KDF_OK } from './ml-kem-braid/kdf.js';
|
|
114
|
+
import { initVersionNegotiation, isVersionNegotiationComplete, processVersionFromByte, } from '../version.js';
|
|
115
|
+
// Validation functions (extracted for modularity)
|
|
116
|
+
import { validateSPQRState, trimSkippedKeys } from './validate.js';
|
|
117
|
+
// SPQR wire format serialization (no circular dependency — pure encode/decode module)
|
|
118
|
+
import { encodeSPQRWire, decodeSPQRWire, spqrInternalEpochToWireEpoch, spqrWireEpochToInternalEpoch, spqrWireEpochToBigInt, } from '../../encoding/proto/pq-ratchet-serialize.js';
|
|
119
|
+
const ZEROED_CHAIN_KEY = bytesToBase64(new Uint8Array(32));
|
|
120
|
+
const SPQR_EPOCH_SECRET_LENGTH = 32;
|
|
121
|
+
function getNextSPQREpoch(spqrState, operation) {
|
|
122
|
+
validateSPQRState(spqrState, operation);
|
|
123
|
+
if (!Number.isSafeInteger(spqrState.epoch) || spqrState.epoch >= Number.MAX_SAFE_INTEGER) {
|
|
124
|
+
throw new EncryptionError(`Cannot advance SPQR epoch safely from ${spqrState.epoch}`, EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { operation, epoch: spqrState.epoch });
|
|
125
|
+
}
|
|
126
|
+
return spqrState.epoch + 1;
|
|
127
|
+
}
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// SPQR Configuration Constants (profile)
|
|
130
|
+
// ============================================================================
|
|
131
|
+
/**
|
|
132
|
+
* SPQR Configuration Constants
|
|
133
|
+
*
|
|
134
|
+
* Security/policy limits are sourced from SPQR_LIMITS_DEFAULTS (DRY).
|
|
135
|
+
* ML-KEM sizes and internal limits remain hardcoded (not configurable).
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* Epochs to retain prior to send epoch.
|
|
140
|
+
*
|
|
141
|
+
* This is a protocol constant, not configurable. Signal hardcodes this value
|
|
142
|
+
* as `EPOCHS_TO_KEEP_PRIOR_TO_SEND_EPOCH: usize = 1` in the profile.
|
|
143
|
+
* Keeping 1 previous epoch means current epoch + 1 previous = 2 total epochs
|
|
144
|
+
* in memory, providing fast forward secrecy while allowing in-flight messages
|
|
145
|
+
* from the previous epoch to be decrypted.
|
|
146
|
+
*/
|
|
147
|
+
const EPOCHS_TO_KEEP_PRIOR_TO_SEND_EPOCH = 1;
|
|
148
|
+
export const SPQR_CONFIG = {
|
|
149
|
+
// ===== Security Limits =====
|
|
150
|
+
// Sourced from SPQR_LIMITS_DEFAULTS for single source of truth
|
|
151
|
+
/** Maximum message number jump allowed (prevents DoS via skipped keys) */
|
|
152
|
+
MAX_MESSAGE_JUMP: SPQR_LIMITS_DEFAULTS.maxMessageJump,
|
|
153
|
+
/** Maximum out-of-order keys to store (limits memory usage) */
|
|
154
|
+
MAX_OOO_KEYS: SPQR_LIMITS_DEFAULTS.maxOutOfOrderKeys,
|
|
155
|
+
/** Maximum old epochs to keep prior to send epoch */
|
|
156
|
+
MAX_EPOCHS_TO_KEEP: EPOCHS_TO_KEEP_PRIOR_TO_SEND_EPOCH,
|
|
157
|
+
// ===== Internal Limits (not configurable) =====
|
|
158
|
+
/**
|
|
159
|
+
* Maximum index per epoch before overflow.
|
|
160
|
+
*
|
|
161
|
+
* Counter should never reach this - triggers epoch rotation.
|
|
162
|
+
*/
|
|
163
|
+
MAX_INDEX: 1000000,
|
|
164
|
+
/** Maximum age for skipped keys before cleanup (7 days) */
|
|
165
|
+
MAX_SKIPPED_KEY_AGE: 7 * 24 * 60 * 60 * 1000,
|
|
166
|
+
// ===== ML-KEM-768 Sizes (NIST FIPS 203) =====
|
|
167
|
+
// Note: SPQR uses ML-KEM-768 for bandwidth efficiency
|
|
168
|
+
// PQXDH uses ML-KEM-1024 for maximum security (see crypto/kyber.ts)
|
|
169
|
+
// Values are literals to ensure `as const` works correctly for module exports
|
|
170
|
+
/** ML-KEM-768 ciphertext size in bytes */
|
|
171
|
+
MLKEM768_CIPHERTEXT_SIZE: 1088,
|
|
172
|
+
/** ML-KEM-768 public key size in bytes */
|
|
173
|
+
MLKEM768_PUBLIC_KEY_SIZE: 1184,
|
|
174
|
+
/** ML-KEM-768 secret key size in bytes */
|
|
175
|
+
MLKEM768_SECRET_KEY_SIZE: 2400,
|
|
176
|
+
/** ML-KEM-768 shared secret size in bytes */
|
|
177
|
+
MLKEM768_SHARED_SECRET_SIZE: 32,
|
|
178
|
+
};
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// SPQR Bootstrap Completeness (Section 3.10)
|
|
181
|
+
// ============================================================================
|
|
182
|
+
/**
|
|
183
|
+
* Check if SPQR bootstrap is complete (profile).
|
|
184
|
+
*
|
|
185
|
+
* The SPQR protocol "locks in" after receiving the first message from
|
|
186
|
+
* the remote party. This is tracked via version negotiation completion, since
|
|
187
|
+
* version capability and Kyber material arrive in the same message.
|
|
188
|
+
*
|
|
189
|
+
* SPQR bootstrap is considered **complete** when:
|
|
190
|
+
* 1. `theirKyberPublicKey` is set (we can encapsulate TO them)
|
|
191
|
+
* 2. Version negotiation is complete (we've received their first message)
|
|
192
|
+
*
|
|
193
|
+
* When bootstrap is incomplete, SPQR key derivation functions return `null`,
|
|
194
|
+
* and the Triple Ratchet uses bootstrap EC keys until SPQR can contribute.
|
|
195
|
+
*
|
|
196
|
+
* @param spqrState - Current SPQR state
|
|
197
|
+
* @returns true if SPQR can derive matching keys on both sides
|
|
198
|
+
*
|
|
199
|
+
* @see https://signal.org/blog/spqr/
|
|
200
|
+
*/
|
|
201
|
+
export function isSpqrBootstrapComplete(spqrState) {
|
|
202
|
+
if (spqrState.mode === 'braid') {
|
|
203
|
+
return !!spqrState.braidState && isVersionNegotiationComplete(spqrState.versionNegotiation);
|
|
204
|
+
}
|
|
205
|
+
// Need their public key to encapsulate TO them
|
|
206
|
+
if (spqrState.sckaState.theirKyberPublicKey === null) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
// Version negotiation complete = received first message from peer
|
|
210
|
+
// = bidirectional exchange confirmed (the SPQR "locked in" state)
|
|
211
|
+
return isVersionNegotiationComplete(spqrState.versionNegotiation);
|
|
212
|
+
}
|
|
213
|
+
// ============================================================================
|
|
214
|
+
// SPQR State Initialization
|
|
215
|
+
// ============================================================================
|
|
216
|
+
/**
|
|
217
|
+
* Initialize SPQR state for a new session.
|
|
218
|
+
*
|
|
219
|
+
* Called during session establishment (X3DH/PQXDH) to set up the
|
|
220
|
+
* Sparse Post-Quantum Ratchet state alongside the EC Double Ratchet.
|
|
221
|
+
*
|
|
222
|
+
* @param initialRootKey - Initial root key (from PQXDH)
|
|
223
|
+
* @param direction - Communication direction ('A2B' or 'B2A')
|
|
224
|
+
* @param ourKyberPrivateKey - Our initial Kyber private key (optional)
|
|
225
|
+
* @param theirKyberPublicKey - Their initial Kyber public key (optional)
|
|
226
|
+
* @param infoStrings - Custom HKDF info strings (optional, defaults to pinned reference)
|
|
227
|
+
* @param limits - Custom security limits (optional, defaults to profile)
|
|
228
|
+
* @returns Initialized SPQR state
|
|
229
|
+
*/
|
|
230
|
+
export async function initializeSPQRState(initialRootKey, direction, ourKyberPrivateKey, theirKyberPublicKey, infoStrings, limits) {
|
|
231
|
+
// Initialize SCKA state
|
|
232
|
+
const sckaState = {
|
|
233
|
+
epoch: 0,
|
|
234
|
+
direction,
|
|
235
|
+
ourKyberPrivateKey: ourKyberPrivateKey ? asBase64(ourKyberPrivateKey) : null,
|
|
236
|
+
theirKyberPublicKey: theirKyberPublicKey ? asBase64(theirKyberPublicKey) : null,
|
|
237
|
+
lastRefreshTimestamp: Date.now(),
|
|
238
|
+
lastRefreshMessageCount: 0,
|
|
239
|
+
};
|
|
240
|
+
// Resolve info strings (use provided or pinned-reference defaults)
|
|
241
|
+
const resolvedInfoStrings = infoStrings ?? resolveSPQRInfoStrings();
|
|
242
|
+
// Per Signal SPQR spec: Initialize chains using profile KDF
|
|
243
|
+
// Uses info string "Signal PQ Ratchet V1 Chain Start" (TWO spaces) with 96-byte output:
|
|
244
|
+
// [0:32] = new root key, [32:64] = A2B chain, [64:96] = B2A chain
|
|
245
|
+
const { rootKey: newRootKey, a2bChainKey, b2aChainKey, } = await kdfSpqrInit(initialRootKey, resolvedInfoStrings.chainStart);
|
|
246
|
+
// Per Signal Protocol Section 5.4 (Output Reordering):
|
|
247
|
+
// - Alice (A2B): send = A2B, receive = B2A (natural order)
|
|
248
|
+
// - Bob (B2A): send = B2A, receive = A2B (swapped order)
|
|
249
|
+
// This ensures Alice's send chain = Bob's receive chain (same bytes)
|
|
250
|
+
const sendChainKey = direction === 'A2B' ? a2bChainKey : b2aChainKey;
|
|
251
|
+
const receiveChainKey = direction === 'A2B' ? b2aChainKey : a2bChainKey;
|
|
252
|
+
let encodedRootKey;
|
|
253
|
+
let encodedSendChainKey;
|
|
254
|
+
let encodedReceiveChainKey;
|
|
255
|
+
try {
|
|
256
|
+
encodedRootKey = bytesToBase64(newRootKey);
|
|
257
|
+
encodedSendChainKey = bytesToBase64(sendChainKey);
|
|
258
|
+
encodedReceiveChainKey = bytesToBase64(receiveChainKey);
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
secureZeroBytes(newRootKey);
|
|
262
|
+
secureZeroBytes(a2bChainKey);
|
|
263
|
+
secureZeroBytes(b2aChainKey);
|
|
264
|
+
}
|
|
265
|
+
// Initialize SPQR state with epoch 0 chains
|
|
266
|
+
// Note: RK is updated to newRootKey from kdfSpqrInit (not initial root key)
|
|
267
|
+
const spqrState = {
|
|
268
|
+
RK: encodedRootKey,
|
|
269
|
+
epoch: 0,
|
|
270
|
+
sendEpoch: 0,
|
|
271
|
+
kdfChains: {
|
|
272
|
+
0: {
|
|
273
|
+
send: {
|
|
274
|
+
CK: encodedSendChainKey,
|
|
275
|
+
N: 0,
|
|
276
|
+
},
|
|
277
|
+
receive: {
|
|
278
|
+
CK: encodedReceiveChainKey,
|
|
279
|
+
N: 0,
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
MKSKIPPED: {},
|
|
284
|
+
direction,
|
|
285
|
+
sckaState,
|
|
286
|
+
mode: 'direct', // Default mode for direct initialization
|
|
287
|
+
// Version negotiation initialized with v1-only defaults
|
|
288
|
+
// Note: This can be overridden by initializeSPQR() if different options provided
|
|
289
|
+
versionNegotiation: initVersionNegotiation('v1', 'v1'),
|
|
290
|
+
// Store resolved info strings for use in subsequent KDF operations
|
|
291
|
+
infoStrings: resolvedInfoStrings,
|
|
292
|
+
// Store resolved limits for use in SPQR operations (DoS protection, epoch retention)
|
|
293
|
+
limits: limits ?? SPQR_LIMITS_DEFAULTS,
|
|
294
|
+
};
|
|
295
|
+
return spqrState;
|
|
296
|
+
}
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// SPQR Epoch Advancement
|
|
299
|
+
// ============================================================================
|
|
300
|
+
/**
|
|
301
|
+
* Add an already-derived SCKA epoch secret to the SPQR chain.
|
|
302
|
+
*
|
|
303
|
+
* This helper deliberately does not apply the `:SCKA Key` KDF. ML-KEM Braid
|
|
304
|
+
* applies that KDF inside its state machine before returning OutputKey.
|
|
305
|
+
*
|
|
306
|
+
* Per `SPQR` the profile add_epoch()`.
|
|
307
|
+
*
|
|
308
|
+
* @param spqrState - SPQR state (mutated)
|
|
309
|
+
* @param epochSecret - Already-derived SCKA epoch secret
|
|
310
|
+
* @param chains - Which chains to initialize: 'both' | 'receive'
|
|
311
|
+
*/
|
|
312
|
+
async function addSPQREpochSecret(spqrState, epochSecret, chains, expectedEpoch) {
|
|
313
|
+
const currentEpoch = spqrState.epoch;
|
|
314
|
+
const nextEpoch = getNextSPQREpoch(spqrState, 'addSPQREpochSecret');
|
|
315
|
+
if (expectedEpoch !== nextEpoch) {
|
|
316
|
+
throw new EncryptionError(`SPQR epoch changed before chain-add: expected ${expectedEpoch}, got ${nextEpoch}`, EncryptionErrorCode.INVALID_STATE, { operation: 'addSPQREpochSecret', expectedEpoch, actualEpoch: nextEpoch });
|
|
317
|
+
}
|
|
318
|
+
if (spqrState.sckaState.epoch !== spqrState.epoch) {
|
|
319
|
+
throw new EncryptionError(`SCKA epoch ${spqrState.sckaState.epoch} does not match SPQR epoch ${spqrState.epoch}`, EncryptionErrorCode.INVALID_STATE, {
|
|
320
|
+
operation: 'addSPQREpochSecret',
|
|
321
|
+
spqrEpoch: spqrState.epoch,
|
|
322
|
+
sckaEpoch: spqrState.sckaState.epoch,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
if (epochSecret.length !== SPQR_EPOCH_SECRET_LENGTH) {
|
|
326
|
+
throw new EncryptionError(`SPQR epoch secret must be ${SPQR_EPOCH_SECRET_LENGTH} bytes, got ${epochSecret.length}`, EncryptionErrorCode.INVALID_STATE, {
|
|
327
|
+
operation: 'addSPQREpochSecret',
|
|
328
|
+
expectedLength: SPQR_EPOCH_SECRET_LENGTH,
|
|
329
|
+
actualLength: epochSecret.length,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
const currentRootKeyBase64 = spqrState.RK;
|
|
333
|
+
const currentRootKey = base64ToBytes(currentRootKeyBase64);
|
|
334
|
+
const ownedDerivedKeys = [];
|
|
335
|
+
try {
|
|
336
|
+
if (currentRootKey.length !== 32) {
|
|
337
|
+
throw new EncryptionError(`SPQR root key must decode to 32 bytes, got ${currentRootKey.length}`, EncryptionErrorCode.INVALID_STATE, {
|
|
338
|
+
operation: 'addSPQREpochSecret',
|
|
339
|
+
expectedLength: 32,
|
|
340
|
+
actualLength: currentRootKey.length,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// Derive and encode every candidate before mutating live state. A validation,
|
|
344
|
+
// KDF, or encoding failure therefore leaves the complete state unchanged.
|
|
345
|
+
const { rootKey: newRootKey, a2bChainKey, b2aChainKey, } = await kdfSpqrEpoch(epochSecret, currentRootKey, spqrState.infoStrings?.chainAddEpoch);
|
|
346
|
+
ownedDerivedKeys.push(newRootKey, a2bChainKey, b2aChainKey);
|
|
347
|
+
const sendChainKey = spqrState.direction === 'A2B' ? a2bChainKey : b2aChainKey;
|
|
348
|
+
const receiveChainKey = spqrState.direction === 'A2B' ? b2aChainKey : a2bChainKey;
|
|
349
|
+
const candidateRootKey = bytesToBase64(newRootKey);
|
|
350
|
+
const candidateSendChainKey = bytesToBase64(sendChainKey);
|
|
351
|
+
const candidateReceiveChainKey = bytesToBase64(receiveChainKey);
|
|
352
|
+
const existingNextEpoch = spqrState.kdfChains[nextEpoch];
|
|
353
|
+
const candidateChains = chains === 'both'
|
|
354
|
+
? {
|
|
355
|
+
send: { CK: candidateSendChainKey, N: 0 },
|
|
356
|
+
receive: { CK: candidateReceiveChainKey, N: 0 },
|
|
357
|
+
}
|
|
358
|
+
: {
|
|
359
|
+
send: existingNextEpoch
|
|
360
|
+
? { ...existingNextEpoch.send }
|
|
361
|
+
: { CK: ZEROED_CHAIN_KEY, N: 0 },
|
|
362
|
+
receive: { CK: candidateReceiveChainKey, N: 0 },
|
|
363
|
+
};
|
|
364
|
+
const candidateRefreshTimestamp = Date.now();
|
|
365
|
+
if (spqrState.epoch !== currentEpoch ||
|
|
366
|
+
spqrState.sckaState.epoch !== currentEpoch ||
|
|
367
|
+
spqrState.RK !== currentRootKeyBase64) {
|
|
368
|
+
throw new EncryptionError('SPQR state changed during chain-add derivation', EncryptionErrorCode.INVALID_STATE, {
|
|
369
|
+
operation: 'addSPQREpochSecret',
|
|
370
|
+
expectedEpoch: currentEpoch,
|
|
371
|
+
actualEpoch: spqrState.epoch,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
// Commit only after the complete candidate exists. The epoch secret is not
|
|
375
|
+
// retained: the chain-add output is the sole persisted authority for it.
|
|
376
|
+
spqrState.RK = candidateRootKey;
|
|
377
|
+
spqrState.kdfChains[nextEpoch] = candidateChains;
|
|
378
|
+
spqrState.epoch = nextEpoch;
|
|
379
|
+
spqrState.sckaState.epoch = nextEpoch;
|
|
380
|
+
spqrState.sckaState.lastRefreshTimestamp = candidateRefreshTimestamp;
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
secureZeroBytes(currentRootKey);
|
|
384
|
+
for (const key of ownedDerivedKeys)
|
|
385
|
+
secureZeroBytes(key);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Advance direct ML-KEM mode from raw KEM output.
|
|
390
|
+
*
|
|
391
|
+
* Direct mode does not have a Braid state machine to apply KDF_OK, so it must
|
|
392
|
+
* derive the epoch secret here before invoking the chain-add operation.
|
|
393
|
+
*
|
|
394
|
+
* @internal Deterministic epoch-transition seam; not part of the public API.
|
|
395
|
+
*/
|
|
396
|
+
export async function advanceSPQREpochFromRawSecret(spqrState, rawSharedSecret, chains) {
|
|
397
|
+
const nextEpoch = getNextSPQREpoch(spqrState, 'advanceSPQREpochFromRawSecret');
|
|
398
|
+
const epochSecret = await KDF_OK(rawSharedSecret, BigInt(nextEpoch));
|
|
399
|
+
try {
|
|
400
|
+
await addSPQREpochSecret(spqrState, epochSecret, chains, nextEpoch);
|
|
401
|
+
}
|
|
402
|
+
finally {
|
|
403
|
+
secureZeroBytes(epochSecret);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Consume an OutputKey produced by ML-KEM Braid without applying KDF_OK again.
|
|
408
|
+
*
|
|
409
|
+
* Ownership transfers to this function. The caller must not reuse
|
|
410
|
+
* `outputKey.epoch_secret`; it is cleared on both success and failure after the
|
|
411
|
+
* epoch check and candidate derivation have completed.
|
|
412
|
+
*
|
|
413
|
+
* @internal Deterministic epoch-transition seam; not part of the public API.
|
|
414
|
+
*/
|
|
415
|
+
export async function addSPQRBraidEpoch(spqrState, outputKey, chains = 'both') {
|
|
416
|
+
try {
|
|
417
|
+
const expectedEpoch = getNextSPQREpoch(spqrState, 'addSPQRBraidEpoch');
|
|
418
|
+
if (outputKey.epoch !== BigInt(expectedEpoch)) {
|
|
419
|
+
throw new EncryptionError(`Braid output epoch ${outputKey.epoch} does not match next SPQR epoch ${expectedEpoch}`, EncryptionErrorCode.INVALID_STATE, {
|
|
420
|
+
operation: 'addSPQRBraidEpoch',
|
|
421
|
+
expectedEpoch: expectedEpoch.toString(),
|
|
422
|
+
actualEpoch: outputKey.epoch.toString(),
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
await addSPQREpochSecret(spqrState, outputKey.epoch_secret, chains, expectedEpoch);
|
|
426
|
+
}
|
|
427
|
+
finally {
|
|
428
|
+
secureZeroBytes(outputKey.epoch_secret);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// ============================================================================
|
|
432
|
+
// SPQR Ratchet Step (Section 5 & 6)
|
|
433
|
+
// ============================================================================
|
|
434
|
+
/**
|
|
435
|
+
* Perform SPQR ratchet step in parallel with DH ratchet.
|
|
436
|
+
*
|
|
437
|
+
* Signal Protocol Section 6 -
|
|
438
|
+
* "The Triple Ratchet performs DH ratchet and SPQR ratchet in parallel.
|
|
439
|
+
* When the DH ratchet steps (new DH key pair), the SPQR also steps
|
|
440
|
+
* (new Kyber key pair and epoch increment)."
|
|
441
|
+
*
|
|
442
|
+
* This function dispatches based on mode:
|
|
443
|
+
* - **Direct mode**: ML-KEM-768 encapsulation, returns full ciphertext
|
|
444
|
+
* - **Braid mode**: Generates chunks via state machine, returns chunk array
|
|
445
|
+
*
|
|
446
|
+
* @param spqrState - Current SPQR state
|
|
447
|
+
* @returns Updated SPQR state and Kyber ciphertext/chunks to send
|
|
448
|
+
*/
|
|
449
|
+
export async function performSPQRRatchetStep(spqrState) {
|
|
450
|
+
// Validate state before operation
|
|
451
|
+
validateSPQRState(spqrState, 'performSPQRRatchetStep');
|
|
452
|
+
// Mode dispatch: braid mode uses the ML-KEM Braid state machine
|
|
453
|
+
if (spqrState.mode === 'braid') {
|
|
454
|
+
// Import braid operations (lazy to avoid circular deps)
|
|
455
|
+
const { spqrBraidSend } = await import('./braid.js');
|
|
456
|
+
const result = await spqrBraidSend(spqrState);
|
|
457
|
+
return {
|
|
458
|
+
kyberCiphertextToSend: null, // No single ciphertext in braid mode
|
|
459
|
+
kyberPublicKeyToSend: null, // Braid mode handles key exchange differently
|
|
460
|
+
braidChunks: result.chunks,
|
|
461
|
+
outputKey: result.outputKey,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
// Direct mode: standard ML-KEM-768 encapsulation
|
|
465
|
+
// Step 1: Generate new ML-KEM-768 key pair for receiving
|
|
466
|
+
// Note: SPQR uses ML-KEM-768 for bandwidth efficiency (vs ML-KEM-1024 in PQXDH)
|
|
467
|
+
const newKyberKeyPair = await generateKyber768KeyPair();
|
|
468
|
+
try {
|
|
469
|
+
spqrState.sckaState.ourKyberPrivateKey = bytesToBase64(newKyberKeyPair.privateKey);
|
|
470
|
+
}
|
|
471
|
+
finally {
|
|
472
|
+
// The persisted base64 string is immutable; clear the temporary byte key.
|
|
473
|
+
secureZeroBytes(newKyberKeyPair.privateKey);
|
|
474
|
+
}
|
|
475
|
+
// Step 2: Perform ML-KEM-768 encapsulation if we have remote party's public key
|
|
476
|
+
let kyberCiphertextToSend = null;
|
|
477
|
+
let kyberSharedSecret = null;
|
|
478
|
+
try {
|
|
479
|
+
if (spqrState.sckaState.theirKyberPublicKey) {
|
|
480
|
+
const theirPubKeyBytes = base64ToBytes(spqrState.sckaState.theirKyberPublicKey);
|
|
481
|
+
const { sharedSecret, ciphertext } = await kyber768Encapsulate(theirPubKeyBytes);
|
|
482
|
+
kyberSharedSecret = sharedSecret;
|
|
483
|
+
kyberCiphertextToSend = ciphertext;
|
|
484
|
+
}
|
|
485
|
+
// Step 3: Advance epoch with shared secret
|
|
486
|
+
if (!kyberSharedSecret) {
|
|
487
|
+
throw new EncryptionError('SPQR ratchet step requires Kyber shared secret from SCKA', EncryptionErrorCode.SPQR_INVALID_CIPHERTEXT, { operation: 'performSPQRRatchetStep' });
|
|
488
|
+
}
|
|
489
|
+
await advanceSPQREpochFromRawSecret(spqrState, kyberSharedSecret, 'both');
|
|
490
|
+
return {
|
|
491
|
+
kyberCiphertextToSend,
|
|
492
|
+
kyberPublicKeyToSend: newKyberKeyPair.publicKey,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
finally {
|
|
496
|
+
if (kyberSharedSecret)
|
|
497
|
+
secureZeroBytes(kyberSharedSecret);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Process received Kyber ciphertext during SPQR ratchet.
|
|
502
|
+
*
|
|
503
|
+
* Called when receiving a message with a Kyber ciphertext to:
|
|
504
|
+
* 1. Decapsulate the ciphertext to recover shared secret
|
|
505
|
+
* 2. Update remote party's Kyber public key for next ratchet
|
|
506
|
+
* 3. Derive new receiving chain key
|
|
507
|
+
*
|
|
508
|
+
* @param spqrState - Current SPQR state
|
|
509
|
+
* @param receivedKyberCiphertext - Ciphertext from remote party
|
|
510
|
+
*/
|
|
511
|
+
export async function processSPQRReceivedCiphertext(spqrState, receivedKyberCiphertext) {
|
|
512
|
+
// Validate state before operation
|
|
513
|
+
validateSPQRState(spqrState, 'processSPQRReceivedCiphertext');
|
|
514
|
+
// Mode dispatch: braid mode uses chunk-by-chunk processing via spqrBraidReceive
|
|
515
|
+
if (spqrState.mode === 'braid') {
|
|
516
|
+
throw new EncryptionError('Braid mode does not use processSPQRReceivedCiphertext. Use spqrBraidReceive() for chunk-by-chunk processing.', EncryptionErrorCode.INVALID_STATE, {
|
|
517
|
+
operation: 'processSPQRReceivedCiphertext',
|
|
518
|
+
mode: spqrState.mode,
|
|
519
|
+
hint: 'Import spqrBraidReceive from ./braid and call it with each received MLKEMBraidMessage chunk',
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
// Validate ciphertext size before processing (defense-in-depth)
|
|
523
|
+
// Note: ML-KEM decapsulation also validates, but early checks provide better errors.
|
|
524
|
+
if (receivedKyberCiphertext.length !== SPQR_CONFIG.MLKEM768_CIPHERTEXT_SIZE) {
|
|
525
|
+
throw new EncryptionError(`Invalid ML-KEM-768 ciphertext size: ${receivedKyberCiphertext.length} (expected ${SPQR_CONFIG.MLKEM768_CIPHERTEXT_SIZE})`, EncryptionErrorCode.SPQR_INVALID_CIPHERTEXT, {
|
|
526
|
+
receivedSize: receivedKyberCiphertext.length,
|
|
527
|
+
expectedSize: SPQR_CONFIG.MLKEM768_CIPHERTEXT_SIZE,
|
|
528
|
+
operation: 'processSPQRReceivedCiphertext',
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
if (!spqrState.sckaState.ourKyberPrivateKey) {
|
|
532
|
+
throw new EncryptionError('No Kyber private key available for decapsulation', EncryptionErrorCode.SPQR_INVALID_CIPHERTEXT, { operation: 'processSPQRReceivedCiphertext' });
|
|
533
|
+
}
|
|
534
|
+
// Decapsulate to recover shared secret using ML-KEM-768
|
|
535
|
+
const ourPrivKeyBytes = base64ToBytes(spqrState.sckaState.ourKyberPrivateKey);
|
|
536
|
+
let sharedSecret;
|
|
537
|
+
try {
|
|
538
|
+
sharedSecret = await kyber768Decapsulate(receivedKyberCiphertext, ourPrivKeyBytes);
|
|
539
|
+
// Advance epoch with shared secret (receive chain only)
|
|
540
|
+
await advanceSPQREpochFromRawSecret(spqrState, sharedSecret, 'receive');
|
|
541
|
+
}
|
|
542
|
+
finally {
|
|
543
|
+
secureZeroBytes(ourPrivKeyBytes);
|
|
544
|
+
if (sharedSecret)
|
|
545
|
+
secureZeroBytes(sharedSecret);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// ============================================================================
|
|
549
|
+
// SPQR Message Key Derivation
|
|
550
|
+
// ============================================================================
|
|
551
|
+
/**
|
|
552
|
+
* Derive next message key from SPQR sending chain.
|
|
553
|
+
*
|
|
554
|
+
* Called when encrypting a message to derive the PQ message key
|
|
555
|
+
* that will be combined with the EC message key via KDF_HYBRID.
|
|
556
|
+
*
|
|
557
|
+
* @param spqrState - Current SPQR state
|
|
558
|
+
* @returns Message key (32 bytes) and updated message number
|
|
559
|
+
*/
|
|
560
|
+
export async function deriveSPQRSendKey(spqrState, logger = defaultSignalLogger, epochOverride) {
|
|
561
|
+
// Validate state before operation
|
|
562
|
+
validateSPQRState(spqrState, 'deriveSPQRSendKey');
|
|
563
|
+
// Bootstrap completeness check (Section 3.10):
|
|
564
|
+
// During the bootstrap window (before first successful epoch advancement),
|
|
565
|
+
// SPQR cannot derive matching keys on both sides. Return null so the Triple
|
|
566
|
+
// Ratchet keeps using its bootstrap EC key.
|
|
567
|
+
if (!isSpqrBootstrapComplete(spqrState)) {
|
|
568
|
+
logger.debug('SPQR bootstrap incomplete, using bootstrap EC key', {
|
|
569
|
+
category: 'E2EE',
|
|
570
|
+
data: {
|
|
571
|
+
operation: 'deriveSPQRSendKey',
|
|
572
|
+
hasTheirKyber: !!spqrState.sckaState.theirKyberPublicKey,
|
|
573
|
+
currentEpoch: spqrState.epoch,
|
|
574
|
+
reason: 'Bootstrap incomplete - waiting for first epoch advancement',
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
// Log bootstrap complete state (symmetric with "bootstrap incomplete" log above)
|
|
580
|
+
// Uses debug level for consistency - both states logged at same verbosity
|
|
581
|
+
logger.debug('SPQR bootstrap complete, deriving hybrid EC+PQ key', {
|
|
582
|
+
category: 'E2EE',
|
|
583
|
+
data: {
|
|
584
|
+
operation: 'spqr-key-derivation',
|
|
585
|
+
keyMode: 'KDF_HYBRID',
|
|
586
|
+
epoch: spqrState.epoch,
|
|
587
|
+
mode: spqrState.mode,
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
const epoch = epochOverride ?? spqrState.epoch;
|
|
591
|
+
// Get send chain for current epoch
|
|
592
|
+
if (!spqrState.kdfChains[epoch]) {
|
|
593
|
+
throw new EncryptionError(`No KDF chain for epoch ${epoch}`, EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { epoch, operation: 'deriveSPQRSendKey' });
|
|
594
|
+
}
|
|
595
|
+
// Guard against sending from a decreasing epoch (defense-in-depth)
|
|
596
|
+
// Per `SPQR` the profile: reject epoch < send_epoch
|
|
597
|
+
const previousSendEpoch = spqrState.sendEpoch ?? 0;
|
|
598
|
+
if (epoch < previousSendEpoch) {
|
|
599
|
+
throw new EncryptionError('SPQR send epoch decreased', EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { epoch, sendEpoch: previousSendEpoch, operation: 'deriveSPQRSendKey' });
|
|
600
|
+
}
|
|
601
|
+
// M13: Track send_epoch and handle epoch cleanup on advancement.
|
|
602
|
+
// When the send epoch advances, delete old epochs and clear previous send
|
|
603
|
+
// chain keys immediately.
|
|
604
|
+
if (epoch > previousSendEpoch) {
|
|
605
|
+
spqrState.sendEpoch = epoch;
|
|
606
|
+
const oldestToKeep = Math.max(0, epoch - EPOCHS_TO_KEEP_PRIOR_TO_SEND_EPOCH);
|
|
607
|
+
for (const epochStr of Object.keys(spqrState.kdfChains)) {
|
|
608
|
+
const e = parseInt(epochStr, 10);
|
|
609
|
+
if (e < oldestToKeep) {
|
|
610
|
+
// Delete epochs outside the retention window.
|
|
611
|
+
delete spqrState.kdfChains[e];
|
|
612
|
+
}
|
|
613
|
+
else if (e < epoch) {
|
|
614
|
+
// Clear send chain keys (forward secrecy) but keep receive chains
|
|
615
|
+
// for in-flight message decryption
|
|
616
|
+
spqrState.kdfChains[e].send.CK = ZEROED_CHAIN_KEY;
|
|
617
|
+
spqrState.kdfChains[e].send.N = 0;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
logger.debug('SPQR send epoch advanced, old epochs pruned', {
|
|
621
|
+
category: 'E2EE',
|
|
622
|
+
data: {
|
|
623
|
+
operation: 'spqr-send-epoch-advance',
|
|
624
|
+
previousSendEpoch,
|
|
625
|
+
newSendEpoch: epoch,
|
|
626
|
+
oldestEpochKept: oldestToKeep,
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
const sendChain = spqrState.kdfChains[epoch].send;
|
|
631
|
+
// Counter overflow check
|
|
632
|
+
if (sendChain.N >= SPQR_CONFIG.MAX_INDEX) {
|
|
633
|
+
throw new EncryptionError(`SPQR index overflow in epoch ${epoch} (index: ${sendChain.N})`, EncryptionErrorCode.SPQR_COUNTER_OVERFLOW, { epoch, index: sendChain.N, operation: 'deriveSPQRSendKey' });
|
|
634
|
+
}
|
|
635
|
+
const currentChainKey = base64ToBytes(sendChain.CK);
|
|
636
|
+
let newChainKey;
|
|
637
|
+
let messageKey;
|
|
638
|
+
let committed = false;
|
|
639
|
+
try {
|
|
640
|
+
// Pre-increment logically before KDF,
|
|
641
|
+
// but commit the counter only after derivation and encoding succeed.
|
|
642
|
+
const currentIndex = sendChain.N + 1;
|
|
643
|
+
const result = await kdfChainKeySPQR(currentChainKey, currentIndex, spqrState.infoStrings?.chainNext);
|
|
644
|
+
newChainKey = result.chainKey;
|
|
645
|
+
messageKey = result.messageKey;
|
|
646
|
+
const encodedChainKey = bytesToBase64(newChainKey);
|
|
647
|
+
sendChain.CK = encodedChainKey;
|
|
648
|
+
sendChain.N = currentIndex;
|
|
649
|
+
committed = true;
|
|
650
|
+
return {
|
|
651
|
+
messageKey,
|
|
652
|
+
index: currentIndex,
|
|
653
|
+
epoch,
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
finally {
|
|
657
|
+
secureZeroBytes(currentChainKey);
|
|
658
|
+
if (newChainKey)
|
|
659
|
+
secureZeroBytes(newChainKey);
|
|
660
|
+
if (!committed && messageKey)
|
|
661
|
+
secureZeroBytes(messageKey);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Derive message key from SPQR receiving chain.
|
|
666
|
+
*
|
|
667
|
+
* Called when decrypting a message to derive the PQ message key
|
|
668
|
+
* that will be combined with the EC message key via KDF_HYBRID.
|
|
669
|
+
*
|
|
670
|
+
* @param spqrState - Current SPQR state
|
|
671
|
+
* @param index - Message index from header (per Signal SPQR naming)
|
|
672
|
+
* @param epoch - Epoch from header
|
|
673
|
+
* @returns Message key (32 bytes)
|
|
674
|
+
*/
|
|
675
|
+
export async function deriveSPQRReceiveKey(spqrState, index, epoch, logger = defaultSignalLogger) {
|
|
676
|
+
// Validate state before operation
|
|
677
|
+
validateSPQRState(spqrState, 'deriveSPQRReceiveKey');
|
|
678
|
+
// Bootstrap completeness check (Section 3.10):
|
|
679
|
+
// During the bootstrap window, SPQR cannot derive matching keys on both sides.
|
|
680
|
+
// Return null so the Triple Ratchet keeps using its bootstrap EC key.
|
|
681
|
+
//
|
|
682
|
+
// This handles the asymmetric bootstrap scenario after device reset where
|
|
683
|
+
// one party might have advanced their SPQR state but the other hasn't.
|
|
684
|
+
if (!isSpqrBootstrapComplete(spqrState)) {
|
|
685
|
+
logger.debug('SPQR bootstrap incomplete, using bootstrap EC key for decryption', {
|
|
686
|
+
category: 'E2EE',
|
|
687
|
+
data: {
|
|
688
|
+
operation: 'deriveSPQRReceiveKey',
|
|
689
|
+
hasTheirKyber: !!spqrState.sckaState.theirKyberPublicKey,
|
|
690
|
+
currentEpoch: spqrState.epoch,
|
|
691
|
+
requestedEpoch: epoch,
|
|
692
|
+
index,
|
|
693
|
+
reason: 'Bootstrap incomplete - using bootstrap EC key',
|
|
694
|
+
},
|
|
695
|
+
});
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
// Log bootstrap complete state (symmetric with "bootstrap incomplete" log above)
|
|
699
|
+
logger.debug('SPQR bootstrap complete, deriving hybrid EC+PQ key for decryption', {
|
|
700
|
+
category: 'E2EE',
|
|
701
|
+
data: {
|
|
702
|
+
operation: 'spqr-key-derivation',
|
|
703
|
+
keyMode: 'KDF_HYBRID',
|
|
704
|
+
epoch: spqrState.epoch,
|
|
705
|
+
requestedEpoch: epoch,
|
|
706
|
+
index,
|
|
707
|
+
},
|
|
708
|
+
});
|
|
709
|
+
// Check MKSKIPPED first - if this key was already derived and stored (out-of-order),
|
|
710
|
+
// return it directly instead of re-advancing the chain (which would fail for old indices).
|
|
711
|
+
const skipKey = `${epoch}:${index}`;
|
|
712
|
+
if (spqrState.MKSKIPPED[skipKey]) {
|
|
713
|
+
const storedKey = base64ToBytes(spqrState.MKSKIPPED[skipKey].key);
|
|
714
|
+
delete spqrState.MKSKIPPED[skipKey];
|
|
715
|
+
return storedKey;
|
|
716
|
+
}
|
|
717
|
+
// Validate index is non-negative integer
|
|
718
|
+
if (index < 0 || !Number.isInteger(index)) {
|
|
719
|
+
throw new EncryptionError(`Invalid index: ${index}`, EncryptionErrorCode.SPQR_MESSAGE_JUMP_TOO_LARGE, { epoch, index, operation: 'deriveSPQRReceiveKey' });
|
|
720
|
+
}
|
|
721
|
+
// Validate epoch bounds - cannot request future epochs
|
|
722
|
+
if (epoch > spqrState.epoch) {
|
|
723
|
+
throw new EncryptionError(`Future epoch requested: ${epoch} > current ${spqrState.epoch}`, EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { requestedEpoch: epoch, currentEpoch: spqrState.epoch, operation: 'deriveSPQRReceiveKey' });
|
|
724
|
+
}
|
|
725
|
+
// Counter overflow check (mirrors send path at line 895)
|
|
726
|
+
// The sender's send path rejects at N >= MAX_INDEX, so a legitimate sender
|
|
727
|
+
// can never produce an index > MAX_INDEX. Reject early to prevent advancing
|
|
728
|
+
// the receive chain past the limit the sender could never reach.
|
|
729
|
+
if (index > SPQR_CONFIG.MAX_INDEX) {
|
|
730
|
+
throw new EncryptionError(`SPQR index overflow: requested index ${index} exceeds MAX_INDEX ${SPQR_CONFIG.MAX_INDEX}`, EncryptionErrorCode.SPQR_COUNTER_OVERFLOW, { epoch, index, maxIndex: SPQR_CONFIG.MAX_INDEX, operation: 'deriveSPQRReceiveKey' });
|
|
731
|
+
}
|
|
732
|
+
// Validate epoch bounds - cannot request epochs too far in the past
|
|
733
|
+
const oldestEpoch = Math.max(0, spqrState.epoch - EPOCHS_TO_KEEP_PRIOR_TO_SEND_EPOCH);
|
|
734
|
+
if (epoch < oldestEpoch) {
|
|
735
|
+
throw new EncryptionError(`Epoch too old: ${epoch} < oldest kept ${oldestEpoch}`, EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { requestedEpoch: epoch, oldestEpoch, operation: 'deriveSPQRReceiveKey' });
|
|
736
|
+
}
|
|
737
|
+
// Check if we have this epoch's chains
|
|
738
|
+
if (!spqrState.kdfChains[epoch]) {
|
|
739
|
+
throw new EncryptionError(`No KDF chain for epoch ${epoch}`, EncryptionErrorCode.SPQR_EPOCH_OUT_OF_RANGE, { epoch, operation: 'deriveSPQRReceiveKey' });
|
|
740
|
+
}
|
|
741
|
+
const receiveChain = spqrState.kdfChains[epoch].receive;
|
|
742
|
+
const indexGap = index - receiveChain.N;
|
|
743
|
+
// Prevent message jump attacks (Signal max_jump pattern)
|
|
744
|
+
const maxMessageJump = spqrState.limits?.maxMessageJump ?? SPQR_CONFIG.MAX_MESSAGE_JUMP;
|
|
745
|
+
if (indexGap > maxMessageJump) {
|
|
746
|
+
throw new EncryptionError(`Index jump too large: ${indexGap} exceeds max ${maxMessageJump}`, EncryptionErrorCode.SPQR_MESSAGE_JUMP_TOO_LARGE, {
|
|
747
|
+
epoch,
|
|
748
|
+
index,
|
|
749
|
+
currentN: receiveChain.N,
|
|
750
|
+
gap: indexGap,
|
|
751
|
+
operation: 'deriveSPQRReceiveKey',
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
let currentChainKey = base64ToBytes(receiveChain.CK);
|
|
755
|
+
let currentN = receiveChain.N;
|
|
756
|
+
// Advance chain to target index using profile SPQR KDF
|
|
757
|
+
// Counter is 1-indexed
|
|
758
|
+
let messageKey = null;
|
|
759
|
+
const pendingSkipped = [];
|
|
760
|
+
let committed = false;
|
|
761
|
+
try {
|
|
762
|
+
while (currentN < index) {
|
|
763
|
+
currentN++;
|
|
764
|
+
const result = await kdfChainKeySPQR(currentChainKey, currentN, spqrState.infoStrings?.chainNext);
|
|
765
|
+
secureZeroBytes(currentChainKey);
|
|
766
|
+
currentChainKey = result.chainKey;
|
|
767
|
+
if (currentN === index) {
|
|
768
|
+
messageKey = result.messageKey;
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
const skipKey = `${epoch}:${currentN}`;
|
|
772
|
+
try {
|
|
773
|
+
pendingSkipped.push([
|
|
774
|
+
skipKey,
|
|
775
|
+
{ key: bytesToBase64(result.messageKey), timestamp: Date.now() },
|
|
776
|
+
]);
|
|
777
|
+
}
|
|
778
|
+
finally {
|
|
779
|
+
secureZeroBytes(result.messageKey);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (!messageKey) {
|
|
784
|
+
throw new EncryptionError(`Failed to derive message key for epoch ${epoch}, index ${index}`, EncryptionErrorCode.DECRYPTION_FAILED, { epoch, index, operation: 'deriveSPQRReceiveKey' });
|
|
785
|
+
}
|
|
786
|
+
const encodedChainKey = bytesToBase64(currentChainKey);
|
|
787
|
+
const maxOOOKeys = spqrState.limits?.maxOutOfOrderKeys ?? SPQR_CONFIG.MAX_OOO_KEYS;
|
|
788
|
+
if (Object.keys(spqrState.MKSKIPPED).length >= maxOOOKeys) {
|
|
789
|
+
trimSkippedKeys(spqrState);
|
|
790
|
+
}
|
|
791
|
+
for (const [skipKey, skipped] of pendingSkipped) {
|
|
792
|
+
spqrState.MKSKIPPED[skipKey] = skipped;
|
|
793
|
+
}
|
|
794
|
+
receiveChain.CK = encodedChainKey;
|
|
795
|
+
receiveChain.N = currentN;
|
|
796
|
+
committed = true;
|
|
797
|
+
return messageKey;
|
|
798
|
+
}
|
|
799
|
+
finally {
|
|
800
|
+
secureZeroBytes(currentChainKey);
|
|
801
|
+
if (!committed && messageKey)
|
|
802
|
+
secureZeroBytes(messageKey);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Try to get a skipped SPQR message key for out-of-order decryption.
|
|
807
|
+
*
|
|
808
|
+
* Checks MKSKIPPED for a previously stored key for out-of-order messages.
|
|
809
|
+
*
|
|
810
|
+
* @param spqrState - Current SPQR state
|
|
811
|
+
* @param epoch - Epoch from message header
|
|
812
|
+
* @param index - Message index from header (per Signal SPQR naming)
|
|
813
|
+
* @returns Message key if found, null otherwise
|
|
814
|
+
*/
|
|
815
|
+
export async function tryGetSkippedSPQRKey(spqrState, epoch, index) {
|
|
816
|
+
const skipKey = `${epoch}:${index}`;
|
|
817
|
+
if (spqrState.MKSKIPPED[skipKey]) {
|
|
818
|
+
const mk = base64ToBytes(spqrState.MKSKIPPED[skipKey].key);
|
|
819
|
+
// Delete used key (forward secrecy)
|
|
820
|
+
delete spqrState.MKSKIPPED[skipKey];
|
|
821
|
+
return mk;
|
|
822
|
+
}
|
|
823
|
+
return null;
|
|
824
|
+
}
|
|
825
|
+
// ============================================================================
|
|
826
|
+
// Version Negotiation
|
|
827
|
+
// ============================================================================
|
|
828
|
+
//
|
|
829
|
+
// Version negotiation functions have been moved to ../version.ts
|
|
830
|
+
// Import them from there:
|
|
831
|
+
// import { initVersionNegotiation, processVersionCapability, ... } from '../version.js';
|
|
832
|
+
//
|
|
833
|
+
// Or use the re-exports from ./index.ts.
|
|
834
|
+
//
|
|
835
|
+
// ============================================================================
|
|
836
|
+
// ============================================================================
|
|
837
|
+
// SPQR Cleanup
|
|
838
|
+
// ============================================================================
|
|
839
|
+
/**
|
|
840
|
+
* Clean up old SPQR skipped message keys (Section 8.4).
|
|
841
|
+
*
|
|
842
|
+
* Epoch pruning and send-chain clearing happen immediately in
|
|
843
|
+
* deriveSPQRSendKey() when the epoch advances. This function only needs
|
|
844
|
+
* to handle TTL-based cleanup of skipped message keys.
|
|
845
|
+
*
|
|
846
|
+
* @param spqrState - Current SPQR state
|
|
847
|
+
* @param maxAge - Maximum age in milliseconds (default: from state.limits or 7 days)
|
|
848
|
+
*/
|
|
849
|
+
export async function cleanupSPQRState(spqrState, maxAge) {
|
|
850
|
+
const now = Date.now();
|
|
851
|
+
const resolvedMaxAge = maxAge ?? SPQR_CONFIG.MAX_SKIPPED_KEY_AGE;
|
|
852
|
+
for (const [key, value] of Object.entries(spqrState.MKSKIPPED)) {
|
|
853
|
+
if (now - value.timestamp > resolvedMaxAge) {
|
|
854
|
+
delete spqrState.MKSKIPPED[key];
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
import { createStateMachine, MessageType } from './ml-kem-braid/index.js';
|
|
859
|
+
let braidStateMachine;
|
|
860
|
+
/**
|
|
861
|
+
* Black-box SPQR send: produce opaque pq_ratchet bytes + message key.
|
|
862
|
+
*
|
|
863
|
+
* This is the Signal `pq_ratchet_send()` pattern.
|
|
864
|
+
* The cipher layer calls this to get opaque bytes for the wire and an optional
|
|
865
|
+
* PQ message key to combine with the EC key via KDF_HYBRID.
|
|
866
|
+
*
|
|
867
|
+
* Internally handles ALL PQ operations:
|
|
868
|
+
* - Lazy KEM: encapsulation + keypair generation when needsSendRatchet is true
|
|
869
|
+
* - Bootstrap: keypair generation when theirKyberPublicKey is null
|
|
870
|
+
* - SPQR key derivation (epoch/index)
|
|
871
|
+
* - Version negotiation capability
|
|
872
|
+
*
|
|
873
|
+
* The DH ratchet never touches post-quantum state.
|
|
874
|
+
*
|
|
875
|
+
* @param state - SPQR state (mutated: KEM state, chain advanced)
|
|
876
|
+
* @returns Opaque bytes and optional message key
|
|
877
|
+
*/
|
|
878
|
+
export async function spqrSend(state, logger = defaultSignalLogger) {
|
|
879
|
+
const emptyResult = { msgBytes: new Uint8Array(0), messageKey: null };
|
|
880
|
+
// Perform the full SPQR ratchet internally when the state requests it.
|
|
881
|
+
let kyberCiphertextToSend;
|
|
882
|
+
let kyberPublicKeyToSend;
|
|
883
|
+
// Direct mode only: needsSendRatchet triggers KEM ratchet step.
|
|
884
|
+
// Braid mode doesn't use this flag — the state machine handles KEM internally,
|
|
885
|
+
// matching the profile, where send() inspects state rather than an external flag.
|
|
886
|
+
if (state.needsSendRatchet && state.mode !== 'braid') {
|
|
887
|
+
if (state.sckaState.theirKyberPublicKey) {
|
|
888
|
+
// Direct mode: full ratchet: encapsulate + advance epoch + derive chains
|
|
889
|
+
const result = await performSPQRRatchetStep(state);
|
|
890
|
+
kyberCiphertextToSend = result.kyberCiphertextToSend ?? undefined;
|
|
891
|
+
kyberPublicKeyToSend = result.kyberPublicKeyToSend ?? undefined;
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
// Bootstrap: generate ML-KEM-768 keypair, send public key
|
|
895
|
+
const newKyberKeyPair = await generateKyber768KeyPair();
|
|
896
|
+
state.sckaState.ourKyberPrivateKey = bytesToBase64(newKyberKeyPair.privateKey);
|
|
897
|
+
kyberPublicKeyToSend = newKyberKeyPair.publicKey;
|
|
898
|
+
}
|
|
899
|
+
state.needsSendRatchet = false;
|
|
900
|
+
}
|
|
901
|
+
// Braid mode: generate one chunk per message (matches the profile's send() pattern)
|
|
902
|
+
let braidMessage;
|
|
903
|
+
if (state.mode === 'braid' && state.braidState) {
|
|
904
|
+
// Stateless singleton — all state is passed as arguments to Send/Receive
|
|
905
|
+
const sm = (braidStateMachine ??= createStateMachine());
|
|
906
|
+
const result = await sm.Send(state.braidState);
|
|
907
|
+
if (result.message.type !== MessageType.None) {
|
|
908
|
+
braidMessage = {
|
|
909
|
+
type: result.message.type,
|
|
910
|
+
epoch: result.message.epoch,
|
|
911
|
+
chunkIndex: result.message.chunkIndex,
|
|
912
|
+
data: result.message.data,
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
if (result.output_key) {
|
|
916
|
+
await addSPQRBraidEpoch(state, result.output_key);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
// Derive SPQR send key (returns null during bootstrap).
|
|
920
|
+
//
|
|
921
|
+
// In braid mode this must happen after the state-machine send so any returned
|
|
922
|
+
// epoch secret is added before deriving the key for the serialized message.
|
|
923
|
+
const sendKeyEpoch = braidMessage !== undefined ? spqrWireEpochToInternalEpoch(braidMessage.epoch) : undefined;
|
|
924
|
+
const spqrKeyResult = await deriveSPQRSendKey(state, logger, sendKeyEpoch);
|
|
925
|
+
// Check if there's any data to send
|
|
926
|
+
const hasData = spqrKeyResult || kyberCiphertextToSend || kyberPublicKeyToSend || braidMessage;
|
|
927
|
+
if (!hasData) {
|
|
928
|
+
return emptyResult;
|
|
929
|
+
}
|
|
930
|
+
// Determine mode
|
|
931
|
+
const isBraid = !!braidMessage;
|
|
932
|
+
const isDirect = !!(kyberCiphertextToSend || kyberPublicKeyToSend);
|
|
933
|
+
const mode = isBraid ? 'braid' : isDirect ? 'direct' : 'none';
|
|
934
|
+
// Encode to compact binary wire format (replaces protobuf envelope)
|
|
935
|
+
// In braid mode, use the braid state machine's epoch (from the message).
|
|
936
|
+
// In direct/none mode, convert the zero-based internal SPQR KDF epoch to
|
|
937
|
+
// the `SPQR` one-based wire epoch.
|
|
938
|
+
const wireEpoch = isBraid
|
|
939
|
+
? braidMessage.epoch
|
|
940
|
+
: spqrInternalEpochToWireEpoch(spqrKeyResult?.epoch ?? state.epoch);
|
|
941
|
+
const msgBytes = encodeSPQRWire({
|
|
942
|
+
version: 1,
|
|
943
|
+
epoch: wireEpoch,
|
|
944
|
+
chainIndex: spqrKeyResult?.index,
|
|
945
|
+
mode,
|
|
946
|
+
// Braid fields
|
|
947
|
+
braidMsgType: braidMessage?.type,
|
|
948
|
+
braidChunkIndex: braidMessage?.chunkIndex,
|
|
949
|
+
braidChunkData: braidMessage?.data,
|
|
950
|
+
// Direct fields
|
|
951
|
+
kyberCiphertext: kyberCiphertextToSend,
|
|
952
|
+
kyberPublicKey: kyberPublicKeyToSend,
|
|
953
|
+
});
|
|
954
|
+
return {
|
|
955
|
+
msgBytes,
|
|
956
|
+
messageKey: spqrKeyResult?.messageKey ?? null,
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Black-box SPQR receive: decode opaque pq_ratchet bytes → message key.
|
|
961
|
+
*
|
|
962
|
+
* This is the Signal `pq_ratchet_recv()` pattern.
|
|
963
|
+
* Called AFTER the DH ratchet step.
|
|
964
|
+
*
|
|
965
|
+
* Internally handles ALL PQ operations:
|
|
966
|
+
* - Version negotiation (process peer's capability)
|
|
967
|
+
* - Kyber public key storage (bootstrap sequence)
|
|
968
|
+
* - Kyber ciphertext decapsulation + epoch advancement
|
|
969
|
+
* - SPQR key derivation (epoch/index)
|
|
970
|
+
* - Sets needsSendRatchet flag for next spqrSend()
|
|
971
|
+
*
|
|
972
|
+
* The cipher layer treats this as an opaque black box — it passes in bytes
|
|
973
|
+
* and gets back an optional key. No SPQR internals leak to the cipher.
|
|
974
|
+
*
|
|
975
|
+
* @param state - SPQR state (mutated: version negotiation, sckaState, chains, needsSendRatchet)
|
|
976
|
+
* @param msgBytes - Opaque pq_ratchet bytes from wire (undefined = no PQ data)
|
|
977
|
+
* @returns PQ message key to combine with EC key via KDF_HYBRID (or null)
|
|
978
|
+
*/
|
|
979
|
+
export async function spqrRecv(state, msgBytes, logger = defaultSignalLogger) {
|
|
980
|
+
// No PQ data during bootstrap or malformed transport with no pq_ratchet field.
|
|
981
|
+
if (!msgBytes || msgBytes.length === 0) {
|
|
982
|
+
return { messageKey: null };
|
|
983
|
+
}
|
|
984
|
+
// Decode compact binary wire format
|
|
985
|
+
const pqr = decodeSPQRWire(msgBytes);
|
|
986
|
+
// 1. Version negotiation via wire format byte 0
|
|
987
|
+
// The `SPQR` format uses the version byte as the capability advertisement.
|
|
988
|
+
if (state.versionNegotiation?.status === 'negotiating') {
|
|
989
|
+
processVersionFromByte(state.versionNegotiation, pqr.version);
|
|
990
|
+
}
|
|
991
|
+
// 2. Process based on mode
|
|
992
|
+
if (pqr.mode === 'direct') {
|
|
993
|
+
// Store their Kyber public key (bootstrap sequence)
|
|
994
|
+
if (pqr.kyberPublicKey?.length) {
|
|
995
|
+
state.sckaState.theirKyberPublicKey = bytesToBase64(pqr.kyberPublicKey);
|
|
996
|
+
}
|
|
997
|
+
// Decapsulate kyber ciphertext → advance epoch + derive receive chains
|
|
998
|
+
if (pqr.kyberCiphertext?.length) {
|
|
999
|
+
await processSPQRReceivedCiphertext(state, pqr.kyberCiphertext);
|
|
1000
|
+
state.needsSendRatchet = true;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
else if (pqr.mode === 'braid' && state.mode === 'braid' && state.braidState) {
|
|
1004
|
+
// Process braid chunk directly from wire fields (no intermediate serialization)
|
|
1005
|
+
// Stateless singleton — all state is passed as arguments to Send/Receive
|
|
1006
|
+
const sm = (braidStateMachine ??= createStateMachine());
|
|
1007
|
+
const chunk = {
|
|
1008
|
+
epoch: spqrWireEpochToBigInt(pqr.epoch ?? 0),
|
|
1009
|
+
type: pqr.braidMsgType ?? 0,
|
|
1010
|
+
chunkIndex: pqr.braidChunkIndex,
|
|
1011
|
+
data: pqr.braidChunkData,
|
|
1012
|
+
};
|
|
1013
|
+
const result = await sm.Receive(state.braidState, chunk);
|
|
1014
|
+
if (result.output_key) {
|
|
1015
|
+
await addSPQRBraidEpoch(state, result.output_key);
|
|
1016
|
+
}
|
|
1017
|
+
// No needsSendRatchet flag — braid state machine drives send behavior
|
|
1018
|
+
// via its own state transitions, matching the profile pattern.
|
|
1019
|
+
}
|
|
1020
|
+
// 3. Derive receive key (epoch now correct after step 2)
|
|
1021
|
+
// Only derive when chainIndex >= 1 — SPQR uses 1-indexed counters (pre-incremented
|
|
1022
|
+
// per the profile). chainIndex 0 means the sender had no SPQR key
|
|
1023
|
+
// result (bootstrap phase), so there's no message key to derive.
|
|
1024
|
+
let messageKey = null;
|
|
1025
|
+
if (pqr.epoch !== undefined && pqr.chainIndex !== undefined && pqr.chainIndex >= 1) {
|
|
1026
|
+
const internalEpoch = spqrWireEpochToInternalEpoch(pqr.epoch);
|
|
1027
|
+
messageKey = await deriveSPQRReceiveKey(state, pqr.chainIndex, internalEpoch, logger);
|
|
1028
|
+
}
|
|
1029
|
+
return { messageKey };
|
|
1030
|
+
}
|
|
1031
|
+
//# sourceMappingURL=spqr.js.map
|