algosdk 3.6.0 → 3.7.0-beta.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.
Files changed (109) hide show
  1. package/dist/browser/algosdk.min.js +1 -1
  2. package/dist/browser/algosdk.min.js.map +1 -1
  3. package/dist/cjs/client/v2/algod/algod.js +0 -18
  4. package/dist/cjs/client/v2/algod/algod.js.map +1 -1
  5. package/dist/cjs/client/v2/algod/models/types.js +2 -434
  6. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  7. package/dist/cjs/ed25519-signer.js +76 -0
  8. package/dist/cjs/ed25519-signer.js.map +1 -0
  9. package/dist/cjs/encoding/address.js +61 -1
  10. package/dist/cjs/encoding/address.js.map +1 -1
  11. package/dist/cjs/falcon-signer.js +17 -0
  12. package/dist/cjs/falcon-signer.js.map +1 -0
  13. package/dist/cjs/logicsig.js +201 -16
  14. package/dist/cjs/logicsig.js.map +1 -1
  15. package/dist/cjs/main.js +32 -63
  16. package/dist/cjs/main.js.map +1 -1
  17. package/dist/cjs/mnemonic/mnemonic.js +26 -1
  18. package/dist/cjs/mnemonic/mnemonic.js.map +1 -1
  19. package/dist/cjs/multisigSigning.js +78 -1
  20. package/dist/cjs/multisigSigning.js.map +1 -1
  21. package/dist/cjs/pq-signer.js +54 -0
  22. package/dist/cjs/pq-signer.js.map +1 -0
  23. package/dist/cjs/signedTransaction.js +15 -1
  24. package/dist/cjs/signedTransaction.js.map +1 -1
  25. package/dist/cjs/signer.js.map +1 -1
  26. package/dist/cjs/signing.js +94 -7
  27. package/dist/cjs/signing.js.map +1 -1
  28. package/dist/cjs/transaction.js +9 -1
  29. package/dist/cjs/transaction.js.map +1 -1
  30. package/dist/cjs/types/transactions/encoded.js +51 -1
  31. package/dist/cjs/types/transactions/encoded.js.map +1 -1
  32. package/dist/cjs/utils/ed25519-check.js +69 -0
  33. package/dist/cjs/utils/ed25519-check.js.map +1 -0
  34. package/dist/esm/client/v2/algod/algod.js +0 -18
  35. package/dist/esm/client/v2/algod/algod.js.map +1 -1
  36. package/dist/esm/client/v2/algod/models/types.js +0 -427
  37. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  38. package/dist/esm/ed25519-signer.js +72 -0
  39. package/dist/esm/ed25519-signer.js.map +1 -0
  40. package/dist/esm/encoding/address.js +58 -0
  41. package/dist/esm/encoding/address.js.map +1 -1
  42. package/dist/esm/falcon-signer.js +13 -0
  43. package/dist/esm/falcon-signer.js.map +1 -0
  44. package/dist/esm/logicsig.js +200 -15
  45. package/dist/esm/logicsig.js.map +1 -1
  46. package/dist/esm/main.js +8 -56
  47. package/dist/esm/main.js.map +1 -1
  48. package/dist/esm/mnemonic/mnemonic.js +25 -1
  49. package/dist/esm/mnemonic/mnemonic.js.map +1 -1
  50. package/dist/esm/multisigSigning.js +75 -0
  51. package/dist/esm/multisigSigning.js.map +1 -1
  52. package/dist/esm/pq-signer.js +50 -0
  53. package/dist/esm/pq-signer.js.map +1 -0
  54. package/dist/esm/signedTransaction.js +16 -2
  55. package/dist/esm/signedTransaction.js.map +1 -1
  56. package/dist/esm/signer.js.map +1 -1
  57. package/dist/esm/signing.js +91 -8
  58. package/dist/esm/signing.js.map +1 -1
  59. package/dist/esm/transaction.js +9 -1
  60. package/dist/esm/transaction.js.map +1 -1
  61. package/dist/esm/types/transactions/encoded.js +49 -1
  62. package/dist/esm/types/transactions/encoded.js.map +1 -1
  63. package/dist/esm/utils/ed25519-check.js +65 -0
  64. package/dist/esm/utils/ed25519-check.js.map +1 -0
  65. package/dist/types/client/v2/algod/algod.d.ts +0 -16
  66. package/dist/types/client/v2/algod/models/types.d.ts +0 -217
  67. package/dist/types/ed25519-signer.d.ts +7 -0
  68. package/dist/types/encoding/address.d.ts +37 -0
  69. package/dist/types/falcon-signer.d.ts +11 -0
  70. package/dist/types/logicsig.d.ts +72 -1
  71. package/dist/types/main.d.ts +8 -44
  72. package/dist/types/mnemonic/mnemonic.d.ts +13 -0
  73. package/dist/types/multisigSigning.d.ts +49 -0
  74. package/dist/types/pq-signer.d.ts +8 -0
  75. package/dist/types/signedTransaction.d.ts +7 -2
  76. package/dist/types/signer.d.ts +38 -0
  77. package/dist/types/signing.d.ts +45 -0
  78. package/dist/types/transaction.d.ts +9 -0
  79. package/dist/types/types/transactions/encoded.d.ts +27 -0
  80. package/dist/types/utils/ed25519-check.d.ts +10 -0
  81. package/package.json +2 -1
  82. package/src/client/v2/algod/algod.ts +0 -19
  83. package/src/client/v2/algod/models/types.ts +0 -700
  84. package/src/ed25519-signer.ts +125 -0
  85. package/src/encoding/address.ts +80 -0
  86. package/src/falcon-signer.ts +30 -0
  87. package/src/logicsig.ts +258 -16
  88. package/src/main.ts +30 -60
  89. package/src/mnemonic/mnemonic.ts +34 -1
  90. package/src/multisigSigning.ts +111 -0
  91. package/src/pq-signer.ts +90 -0
  92. package/src/signedTransaction.ts +24 -0
  93. package/src/signer.ts +53 -0
  94. package/src/signing.ts +109 -8
  95. package/src/transaction.ts +9 -1
  96. package/src/types/transactions/encoded.ts +88 -0
  97. package/src/utils/ed25519-check.ts +67 -0
  98. package/dist/cjs/client/v2/algod/dryrun.js +0 -34
  99. package/dist/cjs/client/v2/algod/dryrun.js.map +0 -1
  100. package/dist/cjs/dryrun.js +0 -214
  101. package/dist/cjs/dryrun.js.map +0 -1
  102. package/dist/esm/client/v2/algod/dryrun.js +0 -28
  103. package/dist/esm/client/v2/algod/dryrun.js.map +0 -1
  104. package/dist/esm/dryrun.js +0 -208
  105. package/dist/esm/dryrun.js.map +0 -1
  106. package/dist/types/client/v2/algod/dryrun.d.ts +0 -11
  107. package/dist/types/dryrun.d.ts +0 -28
  108. package/src/client/v2/algod/dryrun.ts +0 -38
  109. package/src/dryrun.ts +0 -292
@@ -2,13 +2,17 @@ import { Address } from './encoding/address.js';
2
2
  import * as encoding from './encoding/encoding.js';
3
3
  import { NamedMapSchema } from './encoding/schema/index.js';
4
4
  import { MultisigMetadata } from './multisig.js';
5
- import { EncodedMultisig } from './types/transactions/encoded.js';
5
+ import { EncodedMultisig, EncodedPQSig } from './types/transactions/encoded.js';
6
+ import type { DelegatedLsigSigner, ProgramDataSigner } from './signer.js';
6
7
  /** sanityCheckProgram performs heuristic program validation:
7
8
  * check if passed in bytes are Algorand address or is B64 encoded, rather than Teal bytes
8
9
  *
9
10
  * @param program - Program bytes to check
10
11
  */
11
12
  export declare function sanityCheckProgram(program: Uint8Array): void;
13
+ export declare const PROGRAM_TAG: Uint8Array;
14
+ export declare const PQ_PROGRAM_TAG: Uint8Array;
15
+ export declare const MSIG_PROGRAM_TAG: Uint8Array;
12
16
  /**
13
17
  LogicSig implementation
14
18
 
@@ -21,11 +25,15 @@ export declare class LogicSig implements encoding.Encodable {
21
25
  sig?: Uint8Array;
22
26
  msig?: EncodedMultisig;
23
27
  lmsig?: EncodedMultisig;
28
+ pqsig?: EncodedPQSig;
24
29
  constructor(program: Uint8Array, programArgs?: Array<Uint8Array> | null);
25
30
  getEncodingSchema(): encoding.Schema;
26
31
  toEncodingData(): Map<string, unknown>;
27
32
  static fromEncodingData(data: unknown): LogicSig;
28
33
  /**
34
+ * @deprecated This function does not perform full verification and should not be fully trusted on its own.
35
+ * For example, it does not evaluate programs and does not have the ability to validate PQ signatures.
36
+ *
29
37
  * Performs signature verification
30
38
  * @param publicKey - Verification key (derived from sender address or escrow address)
31
39
  */
@@ -36,21 +44,64 @@ export declare class LogicSig implements encoding.Encodable {
36
44
  */
37
45
  address(): Address;
38
46
  /**
47
+ * @deprecated Use `signWithSigner` instead
48
+ *
39
49
  * Creates signature (if no msig provided) or multi signature otherwise
40
50
  * @param secretKey - Secret key to sign with
41
51
  * @param msig - Multisig account as \{version, threshold, addrs\}
42
52
  */
43
53
  sign(secretKey: Uint8Array, msig?: MultisigMetadata): void;
44
54
  /**
55
+ * Signs this LogicSig for delegation using the given signer.
56
+ *
57
+ * @param signer - The signer to delegate to
58
+ * @param msig - Optional multisig account the signer is a subsigner of
59
+ * @returns The address the signer signed as. When `msig` is omitted this is
60
+ * the delegating account. When `msig` is given it is the individual
61
+ * subsigner, not the multisig, so the delegating account is
62
+ * `multisigAddress(msig)`. Either way it is an authorizing address, which
63
+ * is not necessarily the address a signer sends transactions from.
64
+ *
65
+ * Re-signing an already-signed LogicSig is allowed, and replaces the previous
66
+ * delegation signature. At most one of `sig`, `msig`, `lmsig` and `pqsig` may
67
+ * be set, so any signature left over from an earlier call is cleared.
68
+ */
69
+ signWithSigner(signer: DelegatedLsigSigner, msig?: MultisigMetadata): Promise<Address>;
70
+ /**
71
+ * Removes every delegation signature from this LogicSig, so that exactly one
72
+ * of them can be set afterwards.
73
+ */
74
+ private clearSignatures;
75
+ /**
76
+ * @deprecated Use `appendToMultisigWithSigner` instead
77
+ *
45
78
  * Appends a signature to multi signature
46
79
  * @param secretKey - Secret key to sign with
47
80
  */
48
81
  appendToMultisig(secretKey: Uint8Array): void;
82
+ appendToMultisigWithSigner(signer: DelegatedLsigSigner): Promise<void>;
83
+ /**
84
+ * @deprecated Use `signWithSigner` followed by `.sig` instead
85
+ */
49
86
  signProgram(secretKey: Uint8Array): Uint8Array;
87
+ /**
88
+ * @deprecated Use `signWithSigner` followed by `.sig` instead
89
+ */
50
90
  signProgramMultisig(secretKey: Uint8Array, msig: EncodedMultisig): Uint8Array;
91
+ /**
92
+ * @deprecated Use `signWithSigner` followed by `.sig` instead
93
+ */
51
94
  singleSignMultisig(secretKey: Uint8Array, msig: EncodedMultisig): [sig: Uint8Array, index: number];
52
95
  toByte(): Uint8Array;
53
96
  static fromByte(encoded: ArrayLike<any>): LogicSig;
97
+ /**
98
+ * Signs arbitrary data for use with the `ed25519verify` opcode from within
99
+ * this LogicSig's program.
100
+ *
101
+ * @param signer - The signer to sign the data with
102
+ * @param data - The data to sign
103
+ */
104
+ signDataWithSigner(signer: ProgramDataSigner, data: Uint8Array): Promise<Uint8Array>;
54
105
  }
55
106
  /**
56
107
  * Represents an account that can sign with a LogicSig program.
@@ -90,6 +141,9 @@ export declare class LogicSigAccount implements encoding.Encodable {
90
141
  */
91
142
  isDelegated(): boolean;
92
143
  /**
144
+ * @deprecated This function does not perform full verification and should not be fully trusted on its own.
145
+ * For example, it does not evaluate programs and does not have the ability to validate PQ signatures.
146
+ *
93
147
  * Verifies this LogicSig's program and signatures.
94
148
  * @returns true if and only if the LogicSig program and signatures are valid.
95
149
  */
@@ -105,6 +159,8 @@ export declare class LogicSigAccount implements encoding.Encodable {
105
159
  */
106
160
  address(): Address;
107
161
  /**
162
+ * @deprecated Use `signMultisigWithSigner` instead
163
+ *
108
164
  * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig
109
165
  * has the authority to sign transactions on behalf of another account, called
110
166
  * the delegating account. Use this function if the delegating account is a
@@ -116,7 +172,10 @@ export declare class LogicSigAccount implements encoding.Encodable {
116
172
  * from other members.
117
173
  */
118
174
  signMultisig(msig: MultisigMetadata, secretKey: Uint8Array): void;
175
+ signMultisigWithSigner(msig: MultisigMetadata, signer: DelegatedLsigSigner): Promise<void>;
119
176
  /**
177
+ * @deprecated Use appendToMultisigWithSigner
178
+ *
120
179
  * Adds an additional signature from a member of the delegating multisig
121
180
  * account.
122
181
  *
@@ -124,7 +183,10 @@ export declare class LogicSigAccount implements encoding.Encodable {
124
183
  * multisig account.
125
184
  */
126
185
  appendToMultisig(secretKey: Uint8Array): void;
186
+ appendToMultisigWithSigner(signer: DelegatedLsigSigner): Promise<void>;
127
187
  /**
188
+ * @deprecated Use `signWithSigner` instead
189
+ *
128
190
  * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig
129
191
  * has the authority to sign transactions on behalf of another account, called
130
192
  * the delegating account. If the delegating account is a multisig account,
@@ -133,12 +195,21 @@ export declare class LogicSigAccount implements encoding.Encodable {
133
195
  * @param secretKey - The secret key of the delegating account.
134
196
  */
135
197
  sign(secretKey: Uint8Array): void;
198
+ /**
199
+ * Turns this LogicSigAccount into a delegated LogicSig, signed by the given
200
+ * signer. If the delegating account is a multisig account, use
201
+ * `signMultisigWithSigner` instead.
202
+ *
203
+ * @param signer - The signer of the delegating account.
204
+ */
205
+ signWithSigner(signer: DelegatedLsigSigner): Promise<void>;
136
206
  }
137
207
  /**
138
208
  * logicSigFromByte accepts encoded logic sig bytes and attempts to call logicsig.fromByte on it,
139
209
  * returning the result
140
210
  */
141
211
  export declare function logicSigFromByte(encoded: Uint8Array): LogicSig;
212
+ export declare const SIGN_PROGRAM_DATA_PREFIX: Uint8Array;
142
213
  /**
143
214
  * tealSign creates a signature compatible with ed25519verify opcode from program hash
144
215
  * @param sk - Uint8Array with secret key
@@ -1,42 +1,4 @@
1
- import { Address } from './encoding/address.js';
2
- import { Transaction } from './transaction.js';
3
1
  export declare const MULTISIG_BAD_SENDER_ERROR_MSG = "The transaction sender address and multisig preimage do not match.";
4
- /**
5
- * signTransaction takes an object with either payment or key registration fields and
6
- * a secret key and returns a signed blob.
7
- *
8
- * Payment transaction fields: from, to, amount, fee, firstValid, lastValid, genesisHash,
9
- * note(optional), GenesisID(optional), closeRemainderTo(optional)
10
- *
11
- * Key registration fields: fee, firstValid, lastValid, voteKey, selectionKey, voteFirst,
12
- * voteLast, voteKeyDilution, genesisHash, note(optional), GenesisID(optional)
13
- *
14
- * If flatFee is not set and the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum.
15
- * @param txn - object with either payment or key registration fields
16
- * @param sk - Algorand Secret Key
17
- * @returns object contains the binary signed transaction and its txID
18
- */
19
- export declare function signTransaction(txn: Transaction, sk: Uint8Array): {
20
- txID: string;
21
- blob: Uint8Array;
22
- };
23
- /**
24
- * signBytes takes arbitrary bytes and a secret key, prepends the bytes with "MX" for domain separation, signs the bytes
25
- * with the private key, and returns the signature.
26
- * @param bytes - Uint8array
27
- * @param sk - Algorand secret key
28
- * @returns binary signature
29
- */
30
- export declare function signBytes(bytes: Uint8Array, sk: Uint8Array): Uint8Array;
31
- /**
32
- * verifyBytes takes array of bytes, an address, and a signature and verifies if the signature is correct for the public
33
- * key and the bytes (the bytes should have been signed with "MX" prepended for domain separation).
34
- * @param bytes - Uint8Array
35
- * @param signature - binary signature
36
- * @param addr - string address
37
- * @returns bool
38
- */
39
- export declare function verifyBytes(bytes: Uint8Array, signature: Uint8Array, addr: string | Address): boolean;
40
2
  export declare const ERROR_MULTISIG_BAD_SENDER: Error;
41
3
  export declare const ERROR_INVALID_MICROALGOS: Error;
42
4
  export { AlgodClient as Algodv2 } from './client/v2/algod/algod.js';
@@ -48,7 +10,7 @@ export { BaseHTTPClient, BaseHTTPClientResponse, BaseHTTPClientError, } from './
48
10
  export { AlgodTokenHeader, IndexerTokenHeader, KMDTokenHeader, CustomTokenHeader, TokenHeader, } from './client/urlTokenBaseHTTPClient.js';
49
11
  export { waitForConfirmation } from './wait.js';
50
12
  export { MsgpackEncodingData, JSONEncodingData, Encodable, EncodableClass, encodeObj, decodeObj, msgpackRawEncode, msgpackRawDecode, msgpackRawDecodeAsMap, encodeMsgpack, decodeMsgpack, encodeJSON, decodeJSON, } from './encoding/encoding.js';
51
- export { Address, isValidAddress, encodeAddress, decodeAddress, getApplicationAddress, ALGORAND_ZERO_ADDRESS_STRING, } from './encoding/address.js';
13
+ export { Address, isValidAddress, encodeAddress, decodeAddress, getApplicationAddress, addressFromPQKey, addressFromPQSig, PQ_SCHEME_SIZE, PQ_SALT_MAX, ALGORAND_ZERO_ADDRESS_STRING, } from './encoding/address.js';
52
14
  export { bytesToBigInt, bigIntToBytes } from './encoding/bigint.js';
53
15
  export { base64ToBytes, bytesToBase64, bytesToString, coerceToBytes, bytesToHex, hexToBytes, } from './encoding/binarydata.js';
54
16
  export { encodeUint64, decodeUint64 } from './encoding/uint64.js';
@@ -60,16 +22,18 @@ export * from './stateproof.js';
60
22
  export { UntypedValue } from './client/v2/untypedmodel.js';
61
23
  export * as modelsv2 from './client/v2/algod/models/types.js';
62
24
  export * as indexerModels from './client/v2/indexer/models/types.js';
63
- export { mnemonicToMasterDerivationKey, masterDerivationKeyToMnemonic, secretKeyToMnemonic, mnemonicToSecretKey, seedFromMnemonic, mnemonicFromSeed, } from './mnemonic/mnemonic.js';
25
+ export { mnemonicToMasterDerivationKey, masterDerivationKeyToMnemonic, secretKeyToMnemonic, mnemonicToSecretKey, seedFromMnemonic, mnemonicFromSeed, pq25WordMnemonicToSeed, } from './mnemonic/mnemonic.js';
64
26
  export { microalgosToAlgos, algosToMicroalgos, INVALID_MICROALGOS_ERROR_MSG, } from './convert.js';
65
27
  export { computeGroupID, assignGroupID } from './group.js';
66
28
  export { SignedTransaction, decodeSignedTransaction, encodeUnsignedSimulateTransaction, } from './signedTransaction.js';
67
- export { signLogicSigTransaction, signLogicSigTransactionObject, } from './signing.js';
68
- export { LogicSig, LogicSigAccount, logicSigFromByte, tealSign, tealSignFromProgram, verifyTealSign, } from './logicsig.js';
29
+ export { SIGN_BYTES_PREFIX, signTransaction, signTransactionWithSigner, signBytes, verifyBytes, signLogicSigTransaction, signLogicSigTransactionObject, } from './signing.js';
30
+ export { LogicSig, LogicSigAccount, logicSigFromByte, tealSign, tealSignFromProgram, verifyTealSign, PROGRAM_TAG, PQ_PROGRAM_TAG, MSIG_PROGRAM_TAG, SIGN_PROGRAM_DATA_PREFIX, } from './logicsig.js';
69
31
  export { MultisigMetadata, verifyMultisig, multisigAddress, } from './multisig.js';
70
- export { signMultisigTransaction, mergeMultisigTransactions, appendSignMultisigTransaction, createMultisigTransaction, appendSignRawMultisigSignature, } from './multisigSigning.js';
32
+ export { signMultisigTransaction, mergeMultisigTransactions, appendSignMultisigTransaction, createMultisigTransaction, appendSignRawMultisigSignature, signMultisigTransactionWithSigner, appendSignMultisigTransactionWithSigner, } from './multisigSigning.js';
71
33
  export { ProgramSourceMap, SourceLocation, PcLineLocation, } from './logic/sourcemap.js';
72
- export * from './dryrun.js';
34
+ export { Ed25519SigningKey, addressWithSignersFromRawEd25519Signer, } from './ed25519-signer.js';
35
+ export { FALCON_1024_SCHEME, Falcon1024SigningKey, addressWithSignersFromRawFalcon1024Signer, } from './falcon-signer.js';
36
+ export { PQSigningKey, addressWithSignersFromRawPQSigner, } from './pq-signer.js';
73
37
  export * from './makeTxn.js';
74
38
  export * from './transaction.js';
75
39
  export * from './signer.js';
@@ -41,3 +41,16 @@ export declare function mnemonicToMasterDerivationKey(mn: string): Uint8Array;
41
41
  * @returns string mnemonic
42
42
  */
43
43
  export declare function masterDerivationKeyToMnemonic(mdk: Uint8Array): string;
44
+ /**
45
+ * pq25WordMnemonicToSeed derives a post-quantum key seed from a standard 25-word
46
+ * Algorand mnemonic.
47
+ *
48
+ * The seed is domain-separated by the PQ scheme, so the same mnemonic yields a
49
+ * different key for each scheme, and a different key again from the ed25519
50
+ * account that `mnemonicToSecretKey` derives from it.
51
+ *
52
+ * @param mn - A 25-word Algorand mnemonic
53
+ * @param scheme - The 2-byte ASCII PQ scheme identifier (e.g. "f1" for Falcon-1024)
54
+ * @returns The 32-byte seed to hand to the scheme's key generator
55
+ */
56
+ export declare function pq25WordMnemonicToSeed(mn: string, scheme: Uint8Array): Uint8Array;
@@ -1,6 +1,7 @@
1
1
  import { Address } from './encoding/address.js';
2
2
  import { Transaction } from './transaction.js';
3
3
  import { MultisigMetadata } from './multisig.js';
4
+ import type { TransactionSigner } from './signer.js';
4
5
  export declare const MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG = "Not enough multisig transactions to merge. Need at least two";
5
6
  export declare const MULTISIG_MERGE_MISMATCH_ERROR_MSG = "Cannot merge txs. txIDs differ";
6
7
  export declare const MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG = "Cannot merge txs. Auth addrs differ";
@@ -25,6 +26,8 @@ export declare function createMultisigTransaction(txn: Transaction, { version, t
25
26
  */
26
27
  export declare function mergeMultisigTransactions(multisigTxnBlobs: Uint8Array[]): Uint8Array;
27
28
  /**
29
+ * @deprecated Use {@link signMultisigTransactionWithSigner} instead
30
+ *
28
31
  * signMultisigTransaction takes a raw transaction (see signTransaction), a multisig preimage, a secret key, and returns
29
32
  * a multisig transaction, which is a blob representing a transaction and multisignature account preimage. The returned
30
33
  * multisig txn can accumulate additional signatures through mergeMultisigTransactions or appendSignMultisigTransaction.
@@ -41,6 +44,31 @@ export declare function signMultisigTransaction(txn: Transaction, { version, thr
41
44
  blob: Uint8Array;
42
45
  };
43
46
  /**
47
+ * signMultisigTransactionWithSigner takes a raw transaction, a multisig preimage and a signer, and
48
+ * returns a multisig transaction: a blob representing a transaction and multisignature account
49
+ * preimage. The returned multisig txn can accumulate additional signatures through
50
+ * mergeMultisigTransactions or appendSignMultisigTransactionWithSigner.
51
+ *
52
+ * The signer must hold a key belonging to the multisig. That key is taken from the `sgnr` field of
53
+ * the transaction the signer returns, falling back to the transaction sender when `sgnr` is absent
54
+ * — which is the same convention signers use when writing it. Every signer this SDK provides
55
+ * follows it. Note that `AddressWithTransactionSigner.address` cannot be used for this: it is the
56
+ * address the signer sends transactions from, which for a rekeyed account is not the signing key.
57
+ *
58
+ * @param txn - the transaction to sign
59
+ * @param version - multisig version
60
+ * @param threshold - multisig threshold
61
+ * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
62
+ * @param txnSigner - the signer to sign with
63
+ * @returns an object with txID and blob properties
64
+ */
65
+ export declare function signMultisigTransactionWithSigner(txn: Transaction, { version, threshold, addrs }: MultisigMetadata, txnSigner: TransactionSigner): Promise<{
66
+ txID: string;
67
+ blob: Uint8Array;
68
+ }>;
69
+ /**
70
+ * @deprecated Use {@link appendSignMultisigTransactionWithSigner} instead
71
+ *
44
72
  * appendSignMultisigTransaction takes a multisig transaction blob, and appends our signature to it.
45
73
  * While we could derive public key preimagery from the partially-signed multisig transaction,
46
74
  * we ask the caller to pass it back in, to ensure they know what they are signing.
@@ -55,6 +83,27 @@ export declare function appendSignMultisigTransaction(multisigTxnBlob: Uint8Arra
55
83
  txID: string;
56
84
  blob: Uint8Array;
57
85
  };
86
+ /**
87
+ * appendSignMultisigTransactionWithSigner takes a multisig transaction blob, and appends the given
88
+ * signer's signature to it. While we could derive public key preimagery from the partially-signed
89
+ * multisig transaction, we ask the caller to pass it back in, to ensure they know what they are
90
+ * signing.
91
+ *
92
+ * As with {@link signMultisigTransactionWithSigner}, the signer's key is taken from the `sgnr`
93
+ * field of the transaction it returns, falling back to the transaction sender when `sgnr` is
94
+ * absent.
95
+ *
96
+ * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types.
97
+ * @param version - multisig version
98
+ * @param threshold - multisig threshold
99
+ * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
100
+ * @param txnSigner - the signer to sign with
101
+ * @returns an object with txID and blob properties
102
+ */
103
+ export declare function appendSignMultisigTransactionWithSigner(multisigTxnBlob: Uint8Array, { version, threshold, addrs }: MultisigMetadata, txnSigner: TransactionSigner): Promise<{
104
+ txID: string;
105
+ blob: Uint8Array;
106
+ }>;
58
107
  /**
59
108
  * appendMultisigTransactionSignature takes a multisig transaction blob, and appends a given raw signature to it.
60
109
  * This makes it possible to compile a multisig signature using only raw signatures from external methods.
@@ -0,0 +1,8 @@
1
+ import { Address } from './encoding/address.js';
2
+ import { AddressWithDelegatedLsigSigner, AddressWithTransactionSigner } from './signer.js';
3
+ export interface PQSigningKey {
4
+ pqScheme: Uint8Array;
5
+ pqPublicKey: Uint8Array;
6
+ pqSigner: (bytesToSign: Uint8Array) => Promise<Uint8Array>;
7
+ }
8
+ export declare function addressWithSignersFromRawPQSigner(signingKey: PQSigningKey, sendingAddress?: Address): AddressWithTransactionSigner & AddressWithDelegatedLsigSigner;
@@ -2,7 +2,7 @@ import { Encodable } from './encoding/encoding.js';
2
2
  import { Address } from './encoding/address.js';
3
3
  import { Transaction } from './transaction.js';
4
4
  import { LogicSig } from './logicsig.js';
5
- import { EncodedMultisig } from './types/transactions/index.js';
5
+ import { EncodedMultisig, EncodedPQSig } from './types/transactions/index.js';
6
6
  import { NamedMapSchema } from './encoding/schema/index.js';
7
7
  export declare class SignedTransaction implements Encodable {
8
8
  static readonly encodingSchema: NamedMapSchema;
@@ -22,15 +22,20 @@ export declare class SignedTransaction implements Encodable {
22
22
  * Logic signature
23
23
  */
24
24
  readonly lsig?: LogicSig;
25
+ /**
26
+ * Post-quantum signature
27
+ */
28
+ readonly pqsig?: EncodedPQSig;
25
29
  /**
26
30
  * The signer, if signing with a different key than the Transaction type `sender` property indicates
27
31
  */
28
32
  readonly sgnr?: Address;
29
- constructor({ txn, sig, msig, lsig, sgnr, }: {
33
+ constructor({ txn, sig, msig, lsig, pqsig, sgnr, }: {
30
34
  txn: Transaction;
31
35
  sig?: Uint8Array;
32
36
  msig?: EncodedMultisig;
33
37
  lsig?: LogicSig;
38
+ pqsig?: EncodedPQSig;
34
39
  sgnr?: Address;
35
40
  });
36
41
  getEncodingSchema(): NamedMapSchema;
@@ -2,6 +2,16 @@ import Account from './types/account.js';
2
2
  import { Transaction } from './transaction.js';
3
3
  import { LogicSigAccount } from './logicsig.js';
4
4
  import { MultisigMetadata } from './multisig.js';
5
+ import type { Address } from './encoding/address.js';
6
+ import type { EncodedMultisig, EncodedPQSig } from './types/transactions/encoded.js';
7
+ import type { LogicSig } from './logicsig.js';
8
+ /**
9
+ * Something that has an Algorand address associated with it.
10
+ * It could be logic sig, single-signer account, multisig, app, etc.
11
+ */
12
+ export interface Addressable {
13
+ address: Address;
14
+ }
5
15
  /**
6
16
  * This type represents a function which can sign transactions from an atomic transaction group.
7
17
  * @param txnGroup - The atomic group containing transactions to be signed
@@ -11,6 +21,34 @@ import { MultisigMetadata } from './multisig.js';
11
21
  * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
12
22
  */
13
23
  export type TransactionSigner = (txnGroup: Transaction[], indexesToSign: number[]) => Promise<Uint8Array[]>;
24
+ export interface AddressWithTransactionSigner extends Addressable {
25
+ txnSigner: TransactionSigner;
26
+ }
27
+ /** Function for signing logic signatures for delegation
28
+ * @param lsig - The logic signature that is being signed for delegation
29
+ * @param msig - Optional multisig account that should be set when a public key is signing as a subsigner of a multisig
30
+ * @returns The address of the delegator
31
+ * */
32
+ export type DelegatedLsigSigner = (lsig: LogicSig, msig?: MultisigMetadata) => Promise<{
33
+ address: Address;
34
+ } & ({
35
+ sig: Uint8Array;
36
+ } | {
37
+ lmsig: EncodedMultisig;
38
+ } | {
39
+ pqsig: EncodedPQSig;
40
+ })>;
41
+ export interface AddressWithDelegatedLsigSigner extends Addressable {
42
+ delegatedLsigSigner: DelegatedLsigSigner;
43
+ }
44
+ export type MxBytesSigner = (bytesToSign: Uint8Array) => Promise<Uint8Array>;
45
+ export interface AddressWithMxBytesSigner extends Addressable {
46
+ mxBytesSigner: MxBytesSigner;
47
+ }
48
+ export type ProgramDataSigner = (data: Uint8Array, lsig: LogicSig) => Promise<Uint8Array>;
49
+ export interface AddressWithProgramDataSigner extends Addressable {
50
+ programDataSigner: ProgramDataSigner;
51
+ }
14
52
  /**
15
53
  * Create a TransactionSigner that can sign transactions for the provided basic Account.
16
54
  */
@@ -1,5 +1,50 @@
1
+ import { Address } from './encoding/address.js';
2
+ import { SignedTransaction } from './signedTransaction.js';
1
3
  import { Transaction } from './transaction.js';
2
4
  import { LogicSig, LogicSigAccount } from './logicsig.js';
5
+ import type { TransactionSigner } from './signer.js';
6
+ export declare const SIGN_BYTES_PREFIX: Uint8Array;
7
+ /**
8
+ * @deprecated Use signTransactionWithSigner
9
+ *
10
+ * signTransaction takes an object with either payment or key registration fields and
11
+ * a secret key and returns a signed blob.
12
+ *
13
+ * Payment transaction fields: from, to, amount, fee, firstValid, lastValid, genesisHash,
14
+ * note(optional), GenesisID(optional), closeRemainderTo(optional)
15
+ *
16
+ * Key registration fields: fee, firstValid, lastValid, voteKey, selectionKey, voteFirst,
17
+ * voteLast, voteKeyDilution, genesisHash, note(optional), GenesisID(optional)
18
+ *
19
+ * If flatFee is not set and the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum.
20
+ * @param txn - object with either payment or key registration fields
21
+ * @param sk - Algorand Secret Key
22
+ * @returns object contains the binary signed transaction and its txID
23
+ */
24
+ export declare function signTransaction(txn: Transaction, sk: Uint8Array): {
25
+ txID: string;
26
+ blob: Uint8Array;
27
+ };
28
+ export declare function signTransactionWithSigner(txn: Transaction, signer: TransactionSigner): Promise<ReturnType<typeof signTransaction> & {
29
+ stxn: SignedTransaction;
30
+ }>;
31
+ /**
32
+ * signBytes takes arbitrary bytes and a secret key, prepends the bytes with "MX" for domain separation, signs the bytes
33
+ * with the private key, and returns the signature.
34
+ * @param bytes - Uint8array
35
+ * @param sk - Algorand secret key
36
+ * @returns binary signature
37
+ */
38
+ export declare function signBytes(bytes: Uint8Array, sk: Uint8Array): Uint8Array;
39
+ /**
40
+ * verifyBytes takes array of bytes, an address, and a signature and verifies if the signature is correct for the public
41
+ * key and the bytes (the bytes should have been signed with "MX" prepended for domain separation).
42
+ * @param bytes - Uint8Array
43
+ * @param signature - binary signature
44
+ * @param addr - string address
45
+ * @returns bool
46
+ */
47
+ export declare function verifyBytes(bytes: Uint8Array, signature: Uint8Array, addr: string | Address): boolean;
3
48
  /**
4
49
  * signLogicSigTransactionObject takes a transaction and a LogicSig object and
5
50
  * returns a signed transaction.
@@ -129,7 +129,16 @@ export declare class Transaction implements encoding.Encodable {
129
129
  private estimateSize;
130
130
  bytesToSign(): Uint8Array;
131
131
  toByte(): Uint8Array;
132
+ /**
133
+ * @deprecated Use `(await signTransactionWithSigner(txn, signer)).stxn.sig` instead
134
+ *
135
+ * returns the raw signature
136
+ *
137
+ */
132
138
  rawSignTxn(sk: Uint8Array): Uint8Array;
139
+ /**
140
+ * @deprecated Use `await signTransactionWithSigner(txn, signer)`
141
+ */
133
142
  signTxn(sk: Uint8Array): Uint8Array;
134
143
  attachSignature(signerAddr: string | Address, signature: Uint8Array): Uint8Array;
135
144
  rawTxID(): Uint8Array;
@@ -33,3 +33,30 @@ export interface EncodedMultisig {
33
33
  export declare const ENCODED_MULTISIG_SCHEMA: NamedMapSchema;
34
34
  export declare function encodedMultiSigFromEncodingData(data: unknown): EncodedMultisig;
35
35
  export declare function encodedMultiSigToEncodingData(msig: EncodedMultisig): Map<string, unknown>;
36
+ /**
37
+ * A structure for the encoded post-quantum signature transaction authorization
38
+ * proof. Mirrors the `PQSig` struct from go-algorand.
39
+ */
40
+ export interface EncodedPQSig {
41
+ /**
42
+ * The 2-byte identifier of the post-quantum signature scheme (e.g. "f1"
43
+ * for Falcon-1024).
44
+ */
45
+ sch: Uint8Array;
46
+ /**
47
+ * The 1-byte salt used when deriving the post-quantum account address from the
48
+ * public key.
49
+ */
50
+ slt: number;
51
+ /**
52
+ * The post-quantum public key.
53
+ */
54
+ pk: Uint8Array;
55
+ /**
56
+ * The post-quantum signature over the transaction.
57
+ */
58
+ sig: Uint8Array;
59
+ }
60
+ export declare const ENCODED_PQSIG_SCHEMA: NamedMapSchema;
61
+ export declare function encodedPQSigFromEncodingData(data: unknown): EncodedPQSig;
62
+ export declare function encodedPQSigToEncodingData(pqsig: EncodedPQSig): Map<string, unknown>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Report whether the given bytes decode to an Edwards25519 curve point.
3
+ *
4
+ * This over-approximates whatever the verifier's decoder accepts: small-order
5
+ * points and non-canonical encodings (such as y == p) count as curve points,
6
+ * matching decoders like filippo.io/edwards25519. Over-approximating is the
7
+ * safe direction here, because the only caller uses this to *reject* candidate
8
+ * post-quantum addresses that an Ed25519 key could also occupy.
9
+ */
10
+ export declare function couldBeCurvePoint(keyBytes: Uint8Array): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algosdk",
3
- "version": "3.6.0",
3
+ "version": "3.7.0-beta.1",
4
4
  "description": "The official JavaScript SDK for Algorand",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -75,6 +75,7 @@
75
75
  "eslint-plugin-import": "^2.25.2",
76
76
  "eslint-plugin-tsdoc": "^0.2.11",
77
77
  "express": "^4.19.2",
78
+ "falcon-1024": "1.0.0-beta.2",
78
79
  "geckodriver": "^4.3.0",
79
80
  "husky": "^4.3.8",
80
81
  "lint-staged": "^10.5.4",
@@ -7,7 +7,6 @@ import AccountApplicationsInformation from './accountApplicationsInformation.js'
7
7
  import AccountApplicationInformation from './accountApplicationInformation.js';
8
8
  import Block from './block.js';
9
9
  import Compile from './compile.js';
10
- import Dryrun from './dryrun.js';
11
10
  import Genesis from './genesis.js';
12
11
  import GetAssetByID from './getAssetByID.js';
13
12
  import GetApplicationByID from './getApplicationByID.js';
@@ -460,24 +459,6 @@ export class AlgodClient extends ServiceClient {
460
459
  return new Disassemble(this.c, source);
461
460
  }
462
461
 
463
- /**
464
- * Provides debugging information for a transaction (or group).
465
- *
466
- * Executes TEAL program(s) in context and returns debugging information about the execution. This endpoint is only enabled when a node's configureation file sets `EnableDeveloperAPI` to true.
467
- *
468
- * #### Example
469
- * ```typescript
470
- * const dryRunResult = await algodClient.dryrun(dr).do();
471
- * ```
472
- *
473
- * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealdryrun)
474
- * @param dr
475
- * @category POST
476
- */
477
- dryrun(dr: modelsv2.DryrunRequest) {
478
- return new Dryrun(this.c, dr);
479
- }
480
-
481
462
  /**
482
463
  * Given an asset ID, return asset information including creator, name, total supply and
483
464
  * special addresses.