starknet 11.8.0 → 11.9.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/CHANGELOG.md +12 -0
- package/dist/falcon/index.d.ts +194 -2
- package/dist/falcon/index.js +833 -154
- package/dist/falcon/index.js.map +1 -1
- package/dist/falcon/index.mjs +828 -150
- package/dist/falcon/index.mjs.map +1 -1
- package/dist/index.d.ts +102 -47
- package/dist/index.global.js +130 -67
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +130 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [11.9.1](https://github.com/starknet-io/starknet.js/compare/v11.9.0...v11.9.1) (2026-11-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **calldata:** refuse a Secp256k1Point that is not on the secp256k1 curve ([e13cbee](https://github.com/starknet-io/starknet.js/commit/e13cbee3ba27d06e4a38433ab0f2a6e123bdc792))
|
|
6
|
+
|
|
7
|
+
# [11.9.0](https://github.com/starknet-io/starknet.js/compare/v11.8.0...v11.9.0) (2026-11-23)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **falcon:** share a post-quantum secret between two Falcon accounts with ML-KEM-768 ([5e8aa3f](https://github.com/starknet-io/starknet.js/commit/5e8aa3f46a6e8d41c26aeb366fd453e73f6e4ea1))
|
|
12
|
+
|
|
1
13
|
# [11.8.0](https://github.com/starknet-io/starknet.js/compare/v11.7.2...v11.8.0) (2026-11-23)
|
|
2
14
|
|
|
3
15
|
### Features
|
package/dist/falcon/index.d.ts
CHANGED
|
@@ -438,6 +438,25 @@ declare function importFalconRsSecretKey(secretKey: Uint8Array | string): Uint8A
|
|
|
438
438
|
*/
|
|
439
439
|
declare function exportFalconRsSecretKey(secretKey: Uint8Array | string): Uint8Array;
|
|
440
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Functions for the keys and the signatures of Falcon-512: create a key pair, get its public key
|
|
443
|
+
* (NIST format, or packed in 29 felts), import or export a falcon-rs key, and verify a signature or
|
|
444
|
+
* a SNIP-12 message off-chain. To sign, use `Falcon512Signer`.
|
|
445
|
+
*
|
|
446
|
+
* ```typescript
|
|
447
|
+
* const { secretKey, publicKey } = falcon512.generateKeyPair();
|
|
448
|
+
* const signer = new Falcon512Signer(secretKey, { accountType: 'oz-hint' });
|
|
449
|
+
* const signature = await signer.signMessage(myTypedData, accountAddress);
|
|
450
|
+
* const options = { accountType: 'oz-hint' } as const;
|
|
451
|
+
* const isValid = falcon512.verifyMessage(myTypedData, signature, publicKey, accountAddress, options);
|
|
452
|
+
* // isValid = true
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* Choice of the account, deployment and key change are in the
|
|
456
|
+
* [guide](https://starknet-js.com/docs/guides/account/postQuantum).
|
|
457
|
+
* @module
|
|
458
|
+
*/
|
|
459
|
+
|
|
441
460
|
declare const falcon512_exportFalconRsSecretKey: typeof exportFalconRsSecretKey;
|
|
442
461
|
declare const falcon512_generateKeyPair: typeof generateKeyPair;
|
|
443
462
|
declare const falcon512_getPackedPublicKey: typeof getPackedPublicKey;
|
|
@@ -457,5 +476,178 @@ declare namespace falcon512 {
|
|
|
457
476
|
};
|
|
458
477
|
}
|
|
459
478
|
|
|
460
|
-
|
|
461
|
-
|
|
479
|
+
/** What `createKey` gives to Alice. */
|
|
480
|
+
type MlKemKey = {
|
|
481
|
+
/** 64 random bytes. Alice keeps them secret: `decapsulate` needs them to open a capsule. */
|
|
482
|
+
seed: Uint8Array;
|
|
483
|
+
/** The ML-KEM-768 public key of Alice (1184 bytes). Alice publishes it. */
|
|
484
|
+
publicKey: Uint8Array;
|
|
485
|
+
/** The message that Alice signs with her account, to link the public key to her account. */
|
|
486
|
+
typedData: starknet.TypedData;
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* What Alice publishes: her ML-KEM public key, signed by her account. Bob gives it to
|
|
490
|
+
* `encapsulate`.
|
|
491
|
+
*/
|
|
492
|
+
type MlKemSignedKey = {
|
|
493
|
+
/** The address of the account of Alice, which owns the ML-KEM key. */
|
|
494
|
+
keyOwnerAddress: starknet.BigNumberish;
|
|
495
|
+
/** The ML-KEM-768 public key of Alice (1184 bytes). */
|
|
496
|
+
publicKey: Uint8Array;
|
|
497
|
+
/** The end of validity of the key, in seconds since 1970-01-01 (UTC). */
|
|
498
|
+
validUntil: number;
|
|
499
|
+
/** The signature of the message of `createKey`, by the account of Alice. */
|
|
500
|
+
signature: starknet.Signature;
|
|
501
|
+
};
|
|
502
|
+
/** What `encapsulate` gives to Bob. */
|
|
503
|
+
type MlKemEncapsulation = {
|
|
504
|
+
/** The shared secret (32 bytes). Bob keeps it secret. */
|
|
505
|
+
sharedSecret: Uint8Array;
|
|
506
|
+
/** The capsule (1088 bytes). Bob sends it to Alice. Only Alice can open it. */
|
|
507
|
+
capsule: Uint8Array;
|
|
508
|
+
/** The time of the encapsulation, in seconds since 1970-01-01 (UTC). */
|
|
509
|
+
timestamp: number;
|
|
510
|
+
/** The message that Bob signs with his account, to show that the capsule comes from him. */
|
|
511
|
+
typedData: starknet.TypedData;
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* What Bob sends to Alice: the capsule, signed by his account. Alice gives it to `decapsulate`.
|
|
515
|
+
*/
|
|
516
|
+
type MlKemSignedCapsule = {
|
|
517
|
+
/** The address of the account of Bob, who made the capsule and sent it. */
|
|
518
|
+
senderAddress: starknet.BigNumberish;
|
|
519
|
+
/** The capsule (1088 bytes). */
|
|
520
|
+
capsule: Uint8Array;
|
|
521
|
+
/** The time of the encapsulation, from `encapsulate`. */
|
|
522
|
+
timestamp: number;
|
|
523
|
+
/** The signature of the message of `encapsulate`, by the account of Bob. */
|
|
524
|
+
signature: starknet.Signature;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Step 1, for Alice: creates a new ML-KEM-768 key, and the message that links it to her account.
|
|
529
|
+
* Alice keeps the seed secret. She signs the message with her account (`signMessage`). Then she
|
|
530
|
+
* publishes her public key, its end of validity and the signature (see `MlKemSignedKey`).
|
|
531
|
+
* A wallet can sign the message: it needs nothing new. The seed stays in the dapp.
|
|
532
|
+
* @param {string} chainId the chain id, as `provider.getChainId()` returns it
|
|
533
|
+
* @param {number} validUntil the end of validity of the key, in seconds since 1970-01-01 (UTC).
|
|
534
|
+
* It must be in the future
|
|
535
|
+
* @returns {MlKemKey} the seed, the public key and the message to sign
|
|
536
|
+
* @throws {Error} when the chain id is empty, or when validUntil is not a time in seconds in the
|
|
537
|
+
* future
|
|
538
|
+
* @example
|
|
539
|
+
* ```typescript
|
|
540
|
+
* const chainId = await myProvider.getChainId();
|
|
541
|
+
* const validUntil = Math.floor(Date.now() / 1000) + 30 * 24 * 3600; // in 30 days
|
|
542
|
+
* const aliceKey = mlkem.createKey(chainId, validUntil);
|
|
543
|
+
* const signature = await aliceAccount.signMessage(aliceKey.typedData);
|
|
544
|
+
* const signedKey = {
|
|
545
|
+
* keyOwnerAddress: aliceAccount.address,
|
|
546
|
+
* publicKey: aliceKey.publicKey,
|
|
547
|
+
* validUntil,
|
|
548
|
+
* signature,
|
|
549
|
+
* };
|
|
550
|
+
* // Alice keeps aliceKey.seed (64 bytes) secret, and publishes signedKey.
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
declare function createKey(chainId: string, validUntil: number): MlKemKey;
|
|
554
|
+
/**
|
|
555
|
+
* Step 2, for Bob: checks the signed key of Alice, then creates the shared secret and a capsule.
|
|
556
|
+
* Bob keeps the shared secret. He signs the message with his account (`signMessage`). Then he
|
|
557
|
+
* sends the capsule, the timestamp and the signature to Alice (see `MlKemSignedCapsule`).
|
|
558
|
+
* The function refuses the key when it has expired, or when the account of Alice did not sign it
|
|
559
|
+
* with a post-quantum signature (see `checkSignature`).
|
|
560
|
+
* @param {ProviderInterface} provider the provider of the chain of the exchange
|
|
561
|
+
* @param {MlKemSignedKey} signedKey what Alice published
|
|
562
|
+
* @param {BigNumberish} senderAddress the address of the account of Bob, who makes the capsule
|
|
563
|
+
* and sends it
|
|
564
|
+
* @returns {Promise<MlKemEncapsulation>} the shared secret, the capsule, the timestamp and the
|
|
565
|
+
* message to sign
|
|
566
|
+
* @throws {Error} when the key has a wrong size or has expired, or when the signature of Alice is
|
|
567
|
+
* not valid
|
|
568
|
+
* @example
|
|
569
|
+
* ```typescript
|
|
570
|
+
* const bobSide = await mlkem.encapsulate(myProvider, signedKey, bobAccount.address);
|
|
571
|
+
* const signature = await bobAccount.signMessage(bobSide.typedData);
|
|
572
|
+
* const signedCapsule = {
|
|
573
|
+
* senderAddress: bobAccount.address,
|
|
574
|
+
* capsule: bobSide.capsule,
|
|
575
|
+
* timestamp: bobSide.timestamp,
|
|
576
|
+
* signature,
|
|
577
|
+
* };
|
|
578
|
+
* // Bob keeps bobSide.sharedSecret (32 bytes) secret, and sends signedCapsule to Alice.
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
declare function encapsulate(provider: starknet.ProviderInterface, signedKey: MlKemSignedKey, senderAddress: starknet.BigNumberish): Promise<MlKemEncapsulation>;
|
|
582
|
+
/**
|
|
583
|
+
* Step 3, for Alice: checks the signed capsule of Bob, then opens the capsule. Alice gets the same
|
|
584
|
+
* shared secret as Bob.
|
|
585
|
+
* The function refuses the capsule when the account of Bob did not sign it with a post-quantum
|
|
586
|
+
* signature (see `checkSignature`). A capsule made for another key or for another account is
|
|
587
|
+
* refused too: the signature of Bob does not match.
|
|
588
|
+
* Bob signed the timestamp, so it is the time that Bob gave. To refuse an old capsule, or a
|
|
589
|
+
* capsule received twice, is the job of the application.
|
|
590
|
+
* @param {ProviderInterface} provider the provider of the chain of the exchange
|
|
591
|
+
* @param {MlKemSignedCapsule} signedCapsule what Bob sent
|
|
592
|
+
* @param {BigNumberish} keyOwnerAddress the address of the account of Alice, who owns the key
|
|
593
|
+
* @param {Uint8Array} seed the seed that `createKey` gave to Alice (64 bytes)
|
|
594
|
+
* @returns {Promise<Uint8Array>} the shared secret (32 bytes), the same as the one of Bob
|
|
595
|
+
* @throws {Error} when the capsule or the seed has a wrong size, or when the signature of Bob is
|
|
596
|
+
* not valid
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* const sharedSecret = await mlkem.decapsulate(
|
|
600
|
+
* myProvider,
|
|
601
|
+
* signedCapsule,
|
|
602
|
+
* aliceAccount.address,
|
|
603
|
+
* aliceKey.seed
|
|
604
|
+
* );
|
|
605
|
+
* // sharedSecret = bobSide.sharedSecret (32 bytes)
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
declare function decapsulate(provider: starknet.ProviderInterface, signedCapsule: MlKemSignedCapsule, keyOwnerAddress: starknet.BigNumberish, seed: Uint8Array): Promise<Uint8Array>;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* A post-quantum key exchange between two Falcon-512 accounts of OpenZeppelin, with ML-KEM-768
|
|
612
|
+
* (FIPS 203). Alice and Bob get the same secret of 32 bytes, for example the key of an encrypted
|
|
613
|
+
* message. The secret itself is never sent.
|
|
614
|
+
*
|
|
615
|
+
* 1. Alice calls `createKey`. She keeps the seed secret, signs the message with her account, and
|
|
616
|
+
* sends her public key with the signature (`MlKemSignedKey`).
|
|
617
|
+
* 2. Bob calls `encapsulate`. It first checks the signature of Alice, then gives Bob the secret and
|
|
618
|
+
* a capsule. Bob signs the message with his account, and sends the capsule with the signature
|
|
619
|
+
* (`MlKemSignedCapsule`).
|
|
620
|
+
* 3. Alice calls `decapsulate`. It first checks the signature of Bob, then opens the capsule: Alice
|
|
621
|
+
* gets the same secret.
|
|
622
|
+
*
|
|
623
|
+
* Each signature is checked with the Falcon key that the account stores (`get_public_key`): any
|
|
624
|
+
* other account is refused. A wallet only signs the two messages, with `signMessage`.
|
|
625
|
+
*
|
|
626
|
+
* ```typescript
|
|
627
|
+
* // 1. Alice
|
|
628
|
+
* const aliceKey = mlkem.createKey(await myProvider.getChainId(), validUntil);
|
|
629
|
+
* // 2. Bob, with the key signed by Alice
|
|
630
|
+
* const bobSide = await mlkem.encapsulate(myProvider, signedKey, bobAccount.address);
|
|
631
|
+
* // 3. Alice, with the capsule signed by Bob
|
|
632
|
+
* const secret = await mlkem.decapsulate(myProvider, signedCapsule, aliceAccount.address, aliceKey.seed);
|
|
633
|
+
* // secret = bobSide.sharedSecret
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* The diagram of the exchange, a complete example and the limits are in the
|
|
637
|
+
* [guide](https://starknet-js.com/docs/guides/account/postQuantum#share-a-secret-between-two-falcon-accounts).
|
|
638
|
+
* @module
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
declare const index_createKey: typeof createKey;
|
|
642
|
+
declare const index_decapsulate: typeof decapsulate;
|
|
643
|
+
declare const index_encapsulate: typeof encapsulate;
|
|
644
|
+
declare namespace index {
|
|
645
|
+
export {
|
|
646
|
+
index_createKey as createKey,
|
|
647
|
+
index_decapsulate as decapsulate,
|
|
648
|
+
index_encapsulate as encapsulate,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export { Falcon512Signer, falcon512, index as mlkem };
|
|
653
|
+
export type { Falcon512AccountType, Falcon512KeyPair, Falcon512Options, MlKemEncapsulation, MlKemKey, MlKemSignedCapsule, MlKemSignedKey };
|