@typeberry/lib 0.5.0-b577adc → 0.5.0-c1a86af
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/index.cjs +1329 -536
- package/index.d.ts +81 -34
- package/index.js +1329 -536
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -159,7 +159,6 @@ declare class Compatibility {
|
|
|
159
159
|
static is(...version: GpVersion[]): boolean;
|
|
160
160
|
static isSuite(suite: TestSuite, version?: GpVersion): boolean;
|
|
161
161
|
static isGreaterOrEqual(version: GpVersion): boolean;
|
|
162
|
-
static isLessThan(version: GpVersion): boolean;
|
|
163
162
|
/**
|
|
164
163
|
* Allows selecting different values for different Gray Paper versions from one record.
|
|
165
164
|
*
|
|
@@ -1961,6 +1960,8 @@ declare class TruncatedHashDictionary<T extends OpaqueHash, V> {
|
|
|
1961
1960
|
set(key: T | TruncatedHash, value: V): void;
|
|
1962
1961
|
/** Remove a value that matches the key on `TRUNCATED_HASH_SIZE`. */
|
|
1963
1962
|
delete(key: T | TruncatedHash): void;
|
|
1963
|
+
/** Iterator over keys of the dictionary. */
|
|
1964
|
+
keys(): Iterator<TruncatedHash, any, any> & Iterable<TruncatedHash>;
|
|
1964
1965
|
/** Iterator over values of the dictionary. */
|
|
1965
1966
|
values(): Iterator<V, any, any> & Iterable<V>;
|
|
1966
1967
|
/** Iterator over entries of the dictionary (with truncated keys) */
|
|
@@ -2006,21 +2007,11 @@ declare namespace index$v {
|
|
|
2006
2007
|
}
|
|
2007
2008
|
|
|
2008
2009
|
declare namespace bandersnatch_d_exports {
|
|
2009
|
-
export { batch_verify_tickets, __wbg_init$2 as default, derive_public_key, initSync$2 as initSync, ring_commitment, verify_seal };
|
|
2010
|
+
export { batch_verify_tickets, __wbg_init$2 as default, derive_public_key, generate_seal, initSync$2 as initSync, ring_commitment, verify_seal, vrf_output_hash };
|
|
2010
2011
|
export type { InitInput$2 as InitInput, InitOutput$2 as InitOutput, SyncInitInput$2 as SyncInitInput };
|
|
2011
2012
|
}
|
|
2012
2013
|
/* tslint:disable */
|
|
2013
2014
|
/* eslint-disable */
|
|
2014
|
-
/**
|
|
2015
|
-
* Generate ring commitment given concatenation of ring keys.
|
|
2016
|
-
*/
|
|
2017
|
-
declare function ring_commitment(keys: Uint8Array): Uint8Array;
|
|
2018
|
-
/**
|
|
2019
|
-
* Derive Private and Public Key from Seed
|
|
2020
|
-
*
|
|
2021
|
-
* returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
|
|
2022
|
-
*/
|
|
2023
|
-
declare function derive_public_key(seed: Uint8Array): Uint8Array;
|
|
2024
2015
|
/**
|
|
2025
2016
|
* Seal verification as defined in:
|
|
2026
2017
|
* https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
|
|
@@ -2035,13 +2026,67 @@ declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payl
|
|
|
2035
2026
|
* NOTE: the aux_data of VRF function is empty!
|
|
2036
2027
|
*/
|
|
2037
2028
|
declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
|
|
2029
|
+
/**
|
|
2030
|
+
* Generate seal that is verifiable using `verify_seal` function.
|
|
2031
|
+
*
|
|
2032
|
+
* # Arguments
|
|
2033
|
+
* * `secret_seed` - Seed used to derive the secret key
|
|
2034
|
+
* * `input` - VRF input data
|
|
2035
|
+
* * `aux_data` - Auxiliary data for the VRF proof
|
|
2036
|
+
*
|
|
2037
|
+
* # Returns
|
|
2038
|
+
* A byte vector with the following format:
|
|
2039
|
+
* - On success (97 bytes):
|
|
2040
|
+
* - Byte 0: Status code `0` (RESULT_OK)
|
|
2041
|
+
* - Bytes 1-32: Serialized VRF output (32 bytes, compressed) NOTE: not output hash!
|
|
2042
|
+
* - Bytes 33-96: Serialized IETF VRF proof (64 bytes, compressed)
|
|
2043
|
+
* - On error (1 byte):
|
|
2044
|
+
* - Byte 0: Status code `1` (RESULT_ERR)
|
|
2045
|
+
*
|
|
2046
|
+
* Returns an error if the input cannot be converted to a valid VRF input point
|
|
2047
|
+
* or if serialization of the output or proof fails.
|
|
2048
|
+
*/
|
|
2049
|
+
declare function generate_seal(secret_seed: Uint8Array, input: Uint8Array, aux_data: Uint8Array): Uint8Array;
|
|
2050
|
+
/**
|
|
2051
|
+
* Derive Private and Public Key from Seed
|
|
2052
|
+
*
|
|
2053
|
+
* returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
|
|
2054
|
+
*/
|
|
2055
|
+
declare function derive_public_key(seed: Uint8Array): Uint8Array;
|
|
2056
|
+
/**
|
|
2057
|
+
* Compute VRF output hash from a secret seed and input data.
|
|
2058
|
+
*
|
|
2059
|
+
* This function derives a deterministic VRF output hash without generating a proof.
|
|
2060
|
+
* Unlike `generate_seal`, this produces only the output hash, not a verifiable signature.
|
|
2061
|
+
*
|
|
2062
|
+
* # Arguments
|
|
2063
|
+
* * `secret_seed` - Seed used to derive the secret key
|
|
2064
|
+
* * `input` - VRF input data to be hashed
|
|
2065
|
+
*
|
|
2066
|
+
* # Returns
|
|
2067
|
+
* A byte vector with the following format:
|
|
2068
|
+
* - On success (33 bytes):
|
|
2069
|
+
* - Byte 0: Status code `0` (RESULT_OK)
|
|
2070
|
+
* - Bytes 1-32: VRF output hash (32 bytes)
|
|
2071
|
+
* - On error (1 byte):
|
|
2072
|
+
* - Byte 0: Status code `1` (RESULT_ERR)
|
|
2073
|
+
*
|
|
2074
|
+
* Returns an error if the input cannot be converted to a valid VRF input point.
|
|
2075
|
+
*/
|
|
2076
|
+
declare function vrf_output_hash(secret_seed: Uint8Array, input: Uint8Array): Uint8Array;
|
|
2077
|
+
/**
|
|
2078
|
+
* Generate ring commitment given concatenation of ring keys.
|
|
2079
|
+
*/
|
|
2080
|
+
declare function ring_commitment(keys: Uint8Array): Uint8Array;
|
|
2038
2081
|
type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
2039
2082
|
interface InitOutput$2 {
|
|
2040
2083
|
readonly memory: WebAssembly.Memory;
|
|
2041
|
-
readonly
|
|
2084
|
+
readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
2042
2085
|
readonly derive_public_key: (a: number, b: number) => [number, number];
|
|
2086
|
+
readonly generate_seal: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
2087
|
+
readonly ring_commitment: (a: number, b: number) => [number, number];
|
|
2043
2088
|
readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
2044
|
-
readonly
|
|
2089
|
+
readonly vrf_output_hash: (a: number, b: number, c: number, d: number) => [number, number];
|
|
2045
2090
|
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
2046
2091
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
2047
2092
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
@@ -2724,35 +2769,35 @@ declare class Header extends WithDebug {
|
|
|
2724
2769
|
*
|
|
2725
2770
|
* In case of the genesis block, the hash will be zero.
|
|
2726
2771
|
*/
|
|
2727
|
-
parentHeaderHash: HeaderHash;
|
|
2772
|
+
readonly parentHeaderHash: HeaderHash;
|
|
2728
2773
|
/** `H_r`: The state trie root hash before executing that block. */
|
|
2729
|
-
priorStateRoot: StateRootHash;
|
|
2774
|
+
readonly priorStateRoot: StateRootHash;
|
|
2730
2775
|
/** `H_x`: The hash of block extrinsic. */
|
|
2731
|
-
extrinsicHash: ExtrinsicHash;
|
|
2776
|
+
readonly extrinsicHash: ExtrinsicHash;
|
|
2732
2777
|
/** `H_t`: JAM time-slot index. */
|
|
2733
|
-
timeSlotIndex: TimeSlot;
|
|
2778
|
+
readonly timeSlotIndex: TimeSlot;
|
|
2734
2779
|
/**
|
|
2735
2780
|
* `H_e`: Key and entropy relevant to the following epoch in case the ticket
|
|
2736
2781
|
* contest does not complete adequately.
|
|
2737
2782
|
*/
|
|
2738
|
-
epochMarker: EpochMarker | null;
|
|
2783
|
+
readonly epochMarker: EpochMarker | null;
|
|
2739
2784
|
/**
|
|
2740
2785
|
* `H_w`: Winning tickets provides the series of 600 slot sealing "tickets"
|
|
2741
2786
|
* for the next epoch.
|
|
2742
2787
|
*/
|
|
2743
|
-
ticketsMarker: TicketsMarker | null;
|
|
2788
|
+
readonly ticketsMarker: TicketsMarker | null;
|
|
2744
2789
|
/** `H_i`: Block author's index in the current validator set. */
|
|
2745
|
-
bandersnatchBlockAuthorIndex: ValidatorIndex;
|
|
2790
|
+
readonly bandersnatchBlockAuthorIndex: ValidatorIndex;
|
|
2746
2791
|
/** `H_v`: Entropy-yielding VRF signature. */
|
|
2747
|
-
entropySource: BandersnatchVrfSignature;
|
|
2792
|
+
readonly entropySource: BandersnatchVrfSignature;
|
|
2748
2793
|
/** `H_o`: Sequence of keys of newly misbehaving validators. */
|
|
2749
|
-
offendersMarker: Ed25519Key[];
|
|
2794
|
+
readonly offendersMarker: Ed25519Key[];
|
|
2750
2795
|
/**
|
|
2751
2796
|
* `H_s`: Block seal.
|
|
2752
2797
|
*
|
|
2753
2798
|
* https://graypaper.fluffylabs.dev/#/579bd12/0d0c010d1101
|
|
2754
2799
|
*/
|
|
2755
|
-
seal: BandersnatchVrfSignature;
|
|
2800
|
+
readonly seal: BandersnatchVrfSignature;
|
|
2756
2801
|
private constructor();
|
|
2757
2802
|
/** Create an empty header with some dummy values. */
|
|
2758
2803
|
static empty(): Header;
|
|
@@ -4265,10 +4310,8 @@ declare class JipChainSpec extends WithDebug {
|
|
|
4265
4310
|
|
|
4266
4311
|
/** Block authorship options. */
|
|
4267
4312
|
declare class AuthorshipOptions {
|
|
4268
|
-
/** Use fake seal verification instead of running bandersnatch. */
|
|
4269
|
-
readonly omitSealVerification: boolean;
|
|
4270
4313
|
static fromJson: FromJsonWithParser<unknown, AuthorshipOptions>;
|
|
4271
|
-
static new(
|
|
4314
|
+
static new(): AuthorshipOptions;
|
|
4272
4315
|
private constructor();
|
|
4273
4316
|
}
|
|
4274
4317
|
|
|
@@ -6196,7 +6239,7 @@ declare function serializeStateUpdate(spec: ChainSpec, blake2b: Blake2b, update:
|
|
|
6196
6239
|
* State entries may be wrapped into `SerializedState` to access the contained values.
|
|
6197
6240
|
*/
|
|
6198
6241
|
declare class StateEntries {
|
|
6199
|
-
private readonly
|
|
6242
|
+
private readonly dictionary;
|
|
6200
6243
|
static Codec: Descriptor<StateEntries, StateEntries>;
|
|
6201
6244
|
/** Turn in-memory state into it's serialized form. */
|
|
6202
6245
|
static serializeInMemory(spec: ChainSpec, blake2b: Blake2b, state: InMemoryState): StateEntries;
|
|
@@ -6217,6 +6260,12 @@ declare class StateEntries {
|
|
|
6217
6260
|
private constructor();
|
|
6218
6261
|
/** When comparing, we can safely ignore `trieCache` and just use entries. */
|
|
6219
6262
|
[TEST_COMPARE_USING](): any;
|
|
6263
|
+
/** Iterator over entries */
|
|
6264
|
+
entries(): Generator<[TruncatedHash, BytesBlob]>;
|
|
6265
|
+
/** Iterator over entries keys */
|
|
6266
|
+
keys(): Generator<TruncatedHash>;
|
|
6267
|
+
/** Iterator over entries values */
|
|
6268
|
+
values(): Generator<BytesBlob>;
|
|
6220
6269
|
/** Dump state entries to JSON string (format compatible with stf vectors). */
|
|
6221
6270
|
toString(): string;
|
|
6222
6271
|
[Symbol.iterator](): Generator<[TruncatedHash, BytesBlob], any, any>;
|
|
@@ -9805,7 +9854,7 @@ declare class OnChain {
|
|
|
9805
9854
|
/** Pre-populate things worth caching for the next epoch. */
|
|
9806
9855
|
prepareForNextEpoch(): Promise<void>;
|
|
9807
9856
|
private verifySeal;
|
|
9808
|
-
transition(block: BlockView, headerHash: HeaderHash
|
|
9857
|
+
transition(block: BlockView, headerHash: HeaderHash): Promise<Result<Ok, StfError>>;
|
|
9809
9858
|
private getUsedAuthorizerHashes;
|
|
9810
9859
|
}
|
|
9811
9860
|
|
|
@@ -10085,8 +10134,8 @@ declare class Importer {
|
|
|
10085
10134
|
constructor(spec: ChainSpec, pvm: PvmBackend, hasher: TransitionHasher, logger: Logger, blocks: BlocksDb, states: StatesDb<SerializedState<LeafDb>>);
|
|
10086
10135
|
/** Do some extra work for preparation for the next epoch. */
|
|
10087
10136
|
prepareForNextEpoch(): Promise<void>;
|
|
10088
|
-
importBlockWithStateRoot(block: BlockView
|
|
10089
|
-
importBlock(block: BlockView
|
|
10137
|
+
importBlockWithStateRoot(block: BlockView): Promise<Result<StateRootHash, ImporterError>>;
|
|
10138
|
+
importBlock(block: BlockView): Promise<Result<WithHash<HeaderHash, HeaderView>, ImporterError>>;
|
|
10090
10139
|
private importBlockInternal;
|
|
10091
10140
|
getBestStateRootHash(): (OpaqueHash & WithOpaque<"StateRootHash">) | null;
|
|
10092
10141
|
getBestBlockHash(): OpaqueHash & WithOpaque<"HeaderHash">;
|
|
@@ -10433,13 +10482,11 @@ declare const protocol: LousyProtocol<{
|
|
|
10433
10482
|
type ImporterInternal = Internal<typeof protocol>;
|
|
10434
10483
|
type ImporterApi = Api<typeof protocol>;
|
|
10435
10484
|
declare class ImporterConfig {
|
|
10436
|
-
readonly omitSealVerification: boolean;
|
|
10437
10485
|
readonly pvm: PvmBackend;
|
|
10438
10486
|
static Codec: Descriptor<ImporterConfig, ViewOf<ImporterConfig, {
|
|
10439
|
-
omitSealVerification: Descriptor<boolean, boolean>;
|
|
10440
10487
|
pvm: Descriptor<PvmBackend, U8>;
|
|
10441
10488
|
}>>;
|
|
10442
|
-
static create({
|
|
10489
|
+
static create({ pvm }: CodecRecord<ImporterConfig>): ImporterConfig;
|
|
10443
10490
|
private constructor();
|
|
10444
10491
|
}
|
|
10445
10492
|
|