@typeberry/lib 0.5.0-2b5df1a → 0.5.0-3439612

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 (4) hide show
  1. package/index.cjs +1275 -495
  2. package/index.d.ts +72 -32
  3. package/index.js +1275 -495
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -2005,21 +2005,11 @@ declare namespace index$v {
2005
2005
  }
2006
2006
 
2007
2007
  declare namespace bandersnatch_d_exports {
2008
- export { batch_verify_tickets, __wbg_init$2 as default, derive_public_key, initSync$2 as initSync, ring_commitment, verify_seal };
2008
+ 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 };
2009
2009
  export type { InitInput$2 as InitInput, InitOutput$2 as InitOutput, SyncInitInput$2 as SyncInitInput };
2010
2010
  }
2011
2011
  /* tslint:disable */
2012
2012
  /* eslint-disable */
2013
- /**
2014
- * Generate ring commitment given concatenation of ring keys.
2015
- */
2016
- declare function ring_commitment(keys: Uint8Array): Uint8Array;
2017
- /**
2018
- * Derive Private and Public Key from Seed
2019
- *
2020
- * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
2021
- */
2022
- declare function derive_public_key(seed: Uint8Array): Uint8Array;
2023
2013
  /**
2024
2014
  * Seal verification as defined in:
2025
2015
  * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
@@ -2034,13 +2024,67 @@ declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payl
2034
2024
  * NOTE: the aux_data of VRF function is empty!
2035
2025
  */
2036
2026
  declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
2027
+ /**
2028
+ * Generate seal that is verifiable using `verify_seal` function.
2029
+ *
2030
+ * # Arguments
2031
+ * * `secret_seed` - Seed used to derive the secret key
2032
+ * * `input` - VRF input data
2033
+ * * `aux_data` - Auxiliary data for the VRF proof
2034
+ *
2035
+ * # Returns
2036
+ * A byte vector with the following format:
2037
+ * - On success (97 bytes):
2038
+ * - Byte 0: Status code `0` (RESULT_OK)
2039
+ * - Bytes 1-32: Serialized VRF output (32 bytes, compressed) NOTE: not output hash!
2040
+ * - Bytes 33-96: Serialized IETF VRF proof (64 bytes, compressed)
2041
+ * - On error (1 byte):
2042
+ * - Byte 0: Status code `1` (RESULT_ERR)
2043
+ *
2044
+ * Returns an error if the input cannot be converted to a valid VRF input point
2045
+ * or if serialization of the output or proof fails.
2046
+ */
2047
+ declare function generate_seal(secret_seed: Uint8Array, input: Uint8Array, aux_data: Uint8Array): Uint8Array;
2048
+ /**
2049
+ * Derive Private and Public Key from Seed
2050
+ *
2051
+ * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
2052
+ */
2053
+ declare function derive_public_key(seed: Uint8Array): Uint8Array;
2054
+ /**
2055
+ * Compute VRF output hash from a secret seed and input data.
2056
+ *
2057
+ * This function derives a deterministic VRF output hash without generating a proof.
2058
+ * Unlike `generate_seal`, this produces only the output hash, not a verifiable signature.
2059
+ *
2060
+ * # Arguments
2061
+ * * `secret_seed` - Seed used to derive the secret key
2062
+ * * `input` - VRF input data to be hashed
2063
+ *
2064
+ * # Returns
2065
+ * A byte vector with the following format:
2066
+ * - On success (33 bytes):
2067
+ * - Byte 0: Status code `0` (RESULT_OK)
2068
+ * - Bytes 1-32: VRF output hash (32 bytes)
2069
+ * - On error (1 byte):
2070
+ * - Byte 0: Status code `1` (RESULT_ERR)
2071
+ *
2072
+ * Returns an error if the input cannot be converted to a valid VRF input point.
2073
+ */
2074
+ declare function vrf_output_hash(secret_seed: Uint8Array, input: Uint8Array): Uint8Array;
2075
+ /**
2076
+ * Generate ring commitment given concatenation of ring keys.
2077
+ */
2078
+ declare function ring_commitment(keys: Uint8Array): Uint8Array;
2037
2079
  type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
2038
2080
  interface InitOutput$2 {
2039
2081
  readonly memory: WebAssembly.Memory;
2040
- readonly ring_commitment: (a: number, b: number) => [number, number];
2082
+ readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
2041
2083
  readonly derive_public_key: (a: number, b: number) => [number, number];
2084
+ readonly generate_seal: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
2085
+ readonly ring_commitment: (a: number, b: number) => [number, number];
2042
2086
  readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
2043
- readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
2087
+ readonly vrf_output_hash: (a: number, b: number, c: number, d: number) => [number, number];
2044
2088
  readonly __wbindgen_export_0: WebAssembly.Table;
2045
2089
  readonly __wbindgen_malloc: (a: number, b: number) => number;
2046
2090
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -2723,35 +2767,35 @@ declare class Header extends WithDebug {
2723
2767
  *
2724
2768
  * In case of the genesis block, the hash will be zero.
2725
2769
  */
2726
- parentHeaderHash: HeaderHash;
2770
+ readonly parentHeaderHash: HeaderHash;
2727
2771
  /** `H_r`: The state trie root hash before executing that block. */
2728
- priorStateRoot: StateRootHash;
2772
+ readonly priorStateRoot: StateRootHash;
2729
2773
  /** `H_x`: The hash of block extrinsic. */
2730
- extrinsicHash: ExtrinsicHash;
2774
+ readonly extrinsicHash: ExtrinsicHash;
2731
2775
  /** `H_t`: JAM time-slot index. */
2732
- timeSlotIndex: TimeSlot;
2776
+ readonly timeSlotIndex: TimeSlot;
2733
2777
  /**
2734
2778
  * `H_e`: Key and entropy relevant to the following epoch in case the ticket
2735
2779
  * contest does not complete adequately.
2736
2780
  */
2737
- epochMarker: EpochMarker | null;
2781
+ readonly epochMarker: EpochMarker | null;
2738
2782
  /**
2739
2783
  * `H_w`: Winning tickets provides the series of 600 slot sealing "tickets"
2740
2784
  * for the next epoch.
2741
2785
  */
2742
- ticketsMarker: TicketsMarker | null;
2786
+ readonly ticketsMarker: TicketsMarker | null;
2743
2787
  /** `H_i`: Block author's index in the current validator set. */
2744
- bandersnatchBlockAuthorIndex: ValidatorIndex;
2788
+ readonly bandersnatchBlockAuthorIndex: ValidatorIndex;
2745
2789
  /** `H_v`: Entropy-yielding VRF signature. */
2746
- entropySource: BandersnatchVrfSignature;
2790
+ readonly entropySource: BandersnatchVrfSignature;
2747
2791
  /** `H_o`: Sequence of keys of newly misbehaving validators. */
2748
- offendersMarker: Ed25519Key[];
2792
+ readonly offendersMarker: Ed25519Key[];
2749
2793
  /**
2750
2794
  * `H_s`: Block seal.
2751
2795
  *
2752
2796
  * https://graypaper.fluffylabs.dev/#/579bd12/0d0c010d1101
2753
2797
  */
2754
- seal: BandersnatchVrfSignature;
2798
+ readonly seal: BandersnatchVrfSignature;
2755
2799
  private constructor();
2756
2800
  /** Create an empty header with some dummy values. */
2757
2801
  static empty(): Header;
@@ -4264,10 +4308,8 @@ declare class JipChainSpec extends WithDebug {
4264
4308
 
4265
4309
  /** Block authorship options. */
4266
4310
  declare class AuthorshipOptions {
4267
- /** Use fake seal verification instead of running bandersnatch. */
4268
- readonly omitSealVerification: boolean;
4269
4311
  static fromJson: FromJsonWithParser<unknown, AuthorshipOptions>;
4270
- static new({ omit_seal_verification }: JsonObject<AuthorshipOptions>): AuthorshipOptions;
4312
+ static new(): AuthorshipOptions;
4271
4313
  private constructor();
4272
4314
  }
4273
4315
 
@@ -9804,7 +9846,7 @@ declare class OnChain {
9804
9846
  /** Pre-populate things worth caching for the next epoch. */
9805
9847
  prepareForNextEpoch(): Promise<void>;
9806
9848
  private verifySeal;
9807
- transition(block: BlockView, headerHash: HeaderHash, omitSealVerification?: boolean): Promise<Result<Ok, StfError>>;
9849
+ transition(block: BlockView, headerHash: HeaderHash): Promise<Result<Ok, StfError>>;
9808
9850
  private getUsedAuthorizerHashes;
9809
9851
  }
9810
9852
 
@@ -10084,8 +10126,8 @@ declare class Importer {
10084
10126
  constructor(spec: ChainSpec, pvm: PvmBackend, hasher: TransitionHasher, logger: Logger, blocks: BlocksDb, states: StatesDb<SerializedState<LeafDb>>);
10085
10127
  /** Do some extra work for preparation for the next epoch. */
10086
10128
  prepareForNextEpoch(): Promise<void>;
10087
- importBlockWithStateRoot(block: BlockView, omitSealVerification: boolean): Promise<Result<StateRootHash, ImporterError>>;
10088
- importBlock(block: BlockView, omitSealVerification: boolean): Promise<Result<WithHash<HeaderHash, HeaderView>, ImporterError>>;
10129
+ importBlockWithStateRoot(block: BlockView): Promise<Result<StateRootHash, ImporterError>>;
10130
+ importBlock(block: BlockView): Promise<Result<WithHash<HeaderHash, HeaderView>, ImporterError>>;
10089
10131
  private importBlockInternal;
10090
10132
  getBestStateRootHash(): (OpaqueHash & WithOpaque<"StateRootHash">) | null;
10091
10133
  getBestBlockHash(): OpaqueHash & WithOpaque<"HeaderHash">;
@@ -10432,13 +10474,11 @@ declare const protocol: LousyProtocol<{
10432
10474
  type ImporterInternal = Internal<typeof protocol>;
10433
10475
  type ImporterApi = Api<typeof protocol>;
10434
10476
  declare class ImporterConfig {
10435
- readonly omitSealVerification: boolean;
10436
10477
  readonly pvm: PvmBackend;
10437
10478
  static Codec: Descriptor<ImporterConfig, ViewOf<ImporterConfig, {
10438
- omitSealVerification: Descriptor<boolean, boolean>;
10439
10479
  pvm: Descriptor<PvmBackend, U8>;
10440
10480
  }>>;
10441
- static create({ omitSealVerification, pvm }: CodecRecord<ImporterConfig>): ImporterConfig;
10481
+ static create({ pvm }: CodecRecord<ImporterConfig>): ImporterConfig;
10442
10482
  private constructor();
10443
10483
  }
10444
10484