@leofcoin/chain 1.10.9 → 1.10.11
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/exports/beacon-envelope.js +68 -0
- package/exports/beacon-epoch.js +117 -0
- package/exports/beacon-lifecycle.js +155 -0
- package/exports/beacon-round.js +77 -0
- package/exports/beacon-wire.js +98 -0
- package/exports/beacon.js +141 -0
- package/exports/browser/beacon-envelope.js +163 -0
- package/exports/browser/beacon-epoch.js +116 -0
- package/exports/browser/beacon-lifecycle.js +154 -0
- package/exports/browser/beacon-round.js +76 -0
- package/exports/browser/beacon-wire.js +99 -0
- package/exports/browser/beacon.js +1706 -0
- package/exports/browser/{browser-D-r0O9Qn-BZDYY6cg.js → browser-CWeoyGUw-BabtHowB.js} +4 -2
- package/exports/browser/{browser-_hiyXwPp-DYI1tyUr.js → browser-DvU1xNFS-sdlKNCJc.js} +4 -2
- package/exports/browser/chain.js +174 -5008
- package/exports/browser/{client-BVhUamQG-D-D1e_x8.js → client-B-jyclOB-CsNYfj4Z.js} +6 -4
- package/exports/browser/constants-Cv0p224A.js +130 -0
- package/exports/browser/hkdf-DhdhLAAv.js +147 -0
- package/exports/browser/{index-BD0Anx7_-Dg4_tCeN.js → index-Bxr5Iztg-C6xBk0rK.js} +4 -2
- package/exports/browser/index-CvKt4UDE.js +464 -0
- package/exports/browser/index-D7FUx7Dd.js +4996 -0
- package/exports/browser/{messages-UKnuelZ7-DJT-98q-.js → messages-FMRAS8QX-CvlZBzy5.js} +4 -2
- package/exports/browser/{node-browser-DlzZ5CP_.js → node-browser-xlqSBOaN.js} +12 -5
- package/exports/browser/node-browser.js +4 -2
- package/exports/browser/{constants-gMYZLHKp.js → proposal.proto-BcUgd885.js} +61 -620
- package/exports/browser/quorum-S_qdgiAY.js +8 -0
- package/exports/browser/weierstrass-C-jX_jly.js +2156 -0
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +7142 -72
- package/exports/browser/workers/{worker-CZqErLI7-BxofVJAn.js → worker-DMCj1e6z-CTYVa2yX.js} +30 -1
- package/exports/chain.js +158 -75
- package/exports/{constants-D6gWzJZg.js → constants-CMYKv-Rt.js} +1 -1
- package/exports/node.js +1 -1
- package/exports/quorum-S_qdgiAY.js +8 -0
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +7142 -72
- package/exports/workers/{worker-CZqErLI7-BxofVJAn.js → worker-DMCj1e6z-CTYVa2yX.js} +30 -1
- package/package.json +29 -2
- package/types/beacon-envelope.d.ts +27 -0
- package/types/beacon-epoch.d.ts +28 -0
- package/types/beacon-lifecycle.d.ts +40 -0
- package/types/beacon-round.d.ts +18 -0
- package/types/beacon-wire.d.ts +31 -0
- package/types/beacon.d.ts +24 -0
|
@@ -7929,6 +7929,21 @@ const blockchainCodecs = [
|
|
|
7929
7929
|
}
|
|
7930
7930
|
];
|
|
7931
7931
|
const consensusCodecs = [
|
|
7932
|
+
{
|
|
7933
|
+
name: 'beacon-activation-message',
|
|
7934
|
+
codec: '0x62616d',
|
|
7935
|
+
hashAlg: 'keccak-256'
|
|
7936
|
+
},
|
|
7937
|
+
{
|
|
7938
|
+
name: 'beacon-commitment-message',
|
|
7939
|
+
codec: '0x62636d',
|
|
7940
|
+
hashAlg: 'keccak-256'
|
|
7941
|
+
},
|
|
7942
|
+
{
|
|
7943
|
+
name: 'beacon-share-message',
|
|
7944
|
+
codec: '0x62736d',
|
|
7945
|
+
hashAlg: 'keccak-256'
|
|
7946
|
+
},
|
|
7932
7947
|
{
|
|
7933
7948
|
name: 'proposal-message',
|
|
7934
7949
|
codec: '0x70726d',
|
|
@@ -9053,6 +9068,20 @@ var proto$2 = {
|
|
|
9053
9068
|
reward: BigInt(0)
|
|
9054
9069
|
};
|
|
9055
9070
|
|
|
9071
|
+
({
|
|
9072
|
+
epoch: BigInt(0)});
|
|
9073
|
+
|
|
9074
|
+
({
|
|
9075
|
+
epoch: BigInt(0),
|
|
9076
|
+
threshold: BigInt(0),
|
|
9077
|
+
participant: BigInt(0),
|
|
9078
|
+
commitments: Array()});
|
|
9079
|
+
|
|
9080
|
+
({
|
|
9081
|
+
epoch: BigInt(0),
|
|
9082
|
+
round: BigInt(0),
|
|
9083
|
+
participant: BigInt(0)});
|
|
9084
|
+
|
|
9056
9085
|
var proto$1 = {
|
|
9057
9086
|
creator: String(),
|
|
9058
9087
|
contract: new Uint8Array(),
|
|
@@ -9207,4 +9236,4 @@ class EasyWorker {
|
|
|
9207
9236
|
}
|
|
9208
9237
|
}
|
|
9209
9238
|
|
|
9210
|
-
export { EasyWorker as E, FormatInterface as F, index$2 as a, proto$2 as b,
|
|
9239
|
+
export { EasyWorker as E, FormatInterface as F, index$2 as a, proto$2 as b, jsonParseBigInt$1 as c, proto$1 as d, proto as e, index$3 as i, jsonStringifyBigInt$1 as j, proto$3 as p };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.11",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -12,6 +12,30 @@
|
|
|
12
12
|
"import": "./exports/chain.js",
|
|
13
13
|
"types": "./exports/chain.d.ts"
|
|
14
14
|
},
|
|
15
|
+
"./consensus/beacon": {
|
|
16
|
+
"import": "./exports/beacon.js",
|
|
17
|
+
"types": "./types/beacon.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./consensus/beacon-wire": {
|
|
20
|
+
"import": "./exports/beacon-wire.js",
|
|
21
|
+
"types": "./types/beacon-wire.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./consensus/beacon-envelope": {
|
|
24
|
+
"import": "./exports/beacon-envelope.js",
|
|
25
|
+
"types": "./types/beacon-envelope.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./consensus/beacon-epoch": {
|
|
28
|
+
"import": "./exports/beacon-epoch.js",
|
|
29
|
+
"types": "./types/beacon-epoch.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./consensus/beacon-round": {
|
|
32
|
+
"import": "./exports/beacon-round.js",
|
|
33
|
+
"types": "./types/beacon-round.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./consensus/beacon-lifecycle": {
|
|
36
|
+
"import": "./exports/beacon-lifecycle.js",
|
|
37
|
+
"types": "./types/beacon-lifecycle.d.ts"
|
|
38
|
+
},
|
|
15
39
|
"./browser/node": {
|
|
16
40
|
"import": "./exports/browser/node.js",
|
|
17
41
|
"types": "./exports/node.d.ts"
|
|
@@ -25,6 +49,7 @@
|
|
|
25
49
|
"type": "module",
|
|
26
50
|
"files": [
|
|
27
51
|
"./exports",
|
|
52
|
+
"./types",
|
|
28
53
|
"LICENSE.txt"
|
|
29
54
|
],
|
|
30
55
|
"scripts": {
|
|
@@ -62,6 +87,8 @@
|
|
|
62
87
|
"tslib": "^2.8.1"
|
|
63
88
|
},
|
|
64
89
|
"dependencies": {
|
|
90
|
+
"@noble/curves": "^1.2.0",
|
|
91
|
+
"@noble/hashes": "^1.3.2",
|
|
65
92
|
"@leofcoin/addresses": "^1.0.60",
|
|
66
93
|
"@leofcoin/codecs": "^1.1.4",
|
|
67
94
|
"@leofcoin/contracts": "^0.1.21",
|
|
@@ -71,7 +98,7 @@
|
|
|
71
98
|
"@leofcoin/messages": "^1.6.1",
|
|
72
99
|
"@leofcoin/multi-wallet": "^3.1.9",
|
|
73
100
|
"@leofcoin/networks": "^1.1.30",
|
|
74
|
-
"@leofcoin/peernet": "^1.2.
|
|
101
|
+
"@leofcoin/peernet": "^1.2.28",
|
|
75
102
|
"@leofcoin/storage": "^3.5.38",
|
|
76
103
|
"@leofcoin/utils": "^1.1.45",
|
|
77
104
|
"@leofcoin/workers": "^1.5.34",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type BeaconShareEnvelope = {
|
|
2
|
+
ciphertext: Uint8Array
|
|
3
|
+
ephemeralPublicKey: Uint8Array
|
|
4
|
+
nonce: Uint8Array
|
|
5
|
+
}
|
|
6
|
+
export function createBeaconEncryptionKey(randomPrivateKey?: () => Uint8Array): {
|
|
7
|
+
privateKey: Uint8Array
|
|
8
|
+
publicKey: Uint8Array
|
|
9
|
+
}
|
|
10
|
+
export function encryptBeaconShare(
|
|
11
|
+
share: bigint,
|
|
12
|
+
recipientPublicKey: Uint8Array,
|
|
13
|
+
network: string,
|
|
14
|
+
epoch: bigint,
|
|
15
|
+
sender: string,
|
|
16
|
+
recipient: string,
|
|
17
|
+
randomPrivateKey?: () => Uint8Array,
|
|
18
|
+
randomNonce?: () => Uint8Array
|
|
19
|
+
): Promise<BeaconShareEnvelope>
|
|
20
|
+
export function decryptBeaconShare(
|
|
21
|
+
envelope: BeaconShareEnvelope,
|
|
22
|
+
recipientPrivateKey: Uint8Array,
|
|
23
|
+
network: string,
|
|
24
|
+
epoch: bigint,
|
|
25
|
+
sender: string,
|
|
26
|
+
recipient: string
|
|
27
|
+
): Promise<bigint>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type BeaconEpochDealer = { commitments: string[]; validator: string }
|
|
2
|
+
export type BeaconEpochConfig = {
|
|
3
|
+
dealers: BeaconEpochDealer[]
|
|
4
|
+
epoch: bigint
|
|
5
|
+
threshold: number
|
|
6
|
+
validators: string[]
|
|
7
|
+
}
|
|
8
|
+
export type BeaconActivationVote = {
|
|
9
|
+
configDigest: string
|
|
10
|
+
epoch: bigint
|
|
11
|
+
from: string
|
|
12
|
+
signature: string
|
|
13
|
+
}
|
|
14
|
+
export function beaconParticipants(validators: string[]): Map<string, bigint>
|
|
15
|
+
export function validateBeaconEpochConfig(config: BeaconEpochConfig): boolean
|
|
16
|
+
export function canonicalBeaconEpochConfig(config: BeaconEpochConfig): BeaconEpochConfig
|
|
17
|
+
export function encodeBeaconEpochConfig(config: BeaconEpochConfig): Uint8Array
|
|
18
|
+
export function beaconEpochDigest(config: BeaconEpochConfig): string
|
|
19
|
+
export function beaconEpochGroupPublicKey(config: BeaconEpochConfig): string
|
|
20
|
+
export class BeaconEpochVotes {
|
|
21
|
+
constructor(config: BeaconEpochConfig)
|
|
22
|
+
readonly config: BeaconEpochConfig
|
|
23
|
+
readonly configDigest: string
|
|
24
|
+
add(vote: BeaconActivationVote): 'accepted' | 'duplicate' | 'equivocation' | 'invalid'
|
|
25
|
+
readonly ready: boolean
|
|
26
|
+
certificate(): BeaconActivationVote[]
|
|
27
|
+
equivocation(validator: string): BeaconActivationVote[] | undefined
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BeaconActivationVote, BeaconEpochConfig } from './beacon-epoch.d.ts'
|
|
2
|
+
export type ActiveBeaconEpoch = { certificate: BeaconActivationVote[]; config: BeaconEpochConfig }
|
|
3
|
+
export type PrivateBeaconEpoch = { encryptionPrivateKey: string; epoch: bigint; secretShare: string }
|
|
4
|
+
export function persistPublicBeaconEpoch(store: object, network: string, active: ActiveBeaconEpoch): Promise<void>
|
|
5
|
+
export function loadPublicBeaconEpoch(store: object, network: string, epoch: bigint): Promise<ActiveBeaconEpoch | undefined>
|
|
6
|
+
export function persistPrivateBeaconEpoch(
|
|
7
|
+
store: object,
|
|
8
|
+
network: string,
|
|
9
|
+
validator: string,
|
|
10
|
+
record: PrivateBeaconEpoch,
|
|
11
|
+
sign: (bytes: Uint8Array) => Promise<Uint8Array>,
|
|
12
|
+
randomNonce?: () => Uint8Array
|
|
13
|
+
): Promise<void>
|
|
14
|
+
export function loadPrivateBeaconEpoch(
|
|
15
|
+
store: object,
|
|
16
|
+
network: string,
|
|
17
|
+
validator: string,
|
|
18
|
+
epoch: bigint,
|
|
19
|
+
sign: (bytes: Uint8Array) => Promise<Uint8Array>
|
|
20
|
+
): Promise<PrivateBeaconEpoch | undefined>
|
|
21
|
+
export function clearBeaconEpochStorage(stores: object[], network: string): Promise<void>
|
|
22
|
+
export function restoreBeaconLifecycle(
|
|
23
|
+
publicStore: object,
|
|
24
|
+
privateStore: object,
|
|
25
|
+
network: string,
|
|
26
|
+
validator: string,
|
|
27
|
+
height: number,
|
|
28
|
+
epochLength: number,
|
|
29
|
+
sign: (bytes: Uint8Array) => Promise<Uint8Array>
|
|
30
|
+
): Promise<{ lifecycle: BeaconLifecycle; privateEpoch?: PrivateBeaconEpoch }>
|
|
31
|
+
export class BeaconLifecycle {
|
|
32
|
+
constructor(epochLength: number)
|
|
33
|
+
readonly epochLength: number
|
|
34
|
+
epochAtHeight(height: number): bigint
|
|
35
|
+
ceremonyEpoch(height: number): bigint
|
|
36
|
+
stage(active: ActiveBeaconEpoch): void
|
|
37
|
+
restore(active: ActiveBeaconEpoch): void
|
|
38
|
+
advance(height: number): ActiveBeaconEpoch | undefined
|
|
39
|
+
readonly active: ActiveBeaconEpoch | undefined
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BeaconEpochConfig } from './beacon-epoch.d.ts'
|
|
2
|
+
export type AcceptedBeaconShare = { from: string; participant: bigint; signature: string }
|
|
3
|
+
export type FinalizedBeaconRound = {
|
|
4
|
+
epoch: bigint
|
|
5
|
+
proof: string
|
|
6
|
+
randomness: string
|
|
7
|
+
round: bigint
|
|
8
|
+
signers: string[]
|
|
9
|
+
}
|
|
10
|
+
export class BeaconRound {
|
|
11
|
+
constructor(network: string, config: BeaconEpochConfig, round: bigint, previousProof: Uint8Array)
|
|
12
|
+
readonly epoch: bigint
|
|
13
|
+
readonly round: bigint
|
|
14
|
+
add(share: AcceptedBeaconShare): 'accepted' | 'duplicate' | 'equivocation' | 'invalid'
|
|
15
|
+
readonly ready: boolean
|
|
16
|
+
finalize(): FinalizedBeaconRound
|
|
17
|
+
equivocation(validator: string): AcceptedBeaconShare[] | undefined
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type BeaconCommitmentData = {
|
|
2
|
+
commitments: unknown
|
|
3
|
+
epoch: unknown
|
|
4
|
+
from: unknown
|
|
5
|
+
participant: unknown
|
|
6
|
+
signature?: unknown
|
|
7
|
+
threshold: unknown
|
|
8
|
+
}
|
|
9
|
+
export type BeaconShareData = {
|
|
10
|
+
epoch: unknown
|
|
11
|
+
from: unknown
|
|
12
|
+
participant: unknown
|
|
13
|
+
round: unknown
|
|
14
|
+
signature?: unknown
|
|
15
|
+
signatureShare: unknown
|
|
16
|
+
}
|
|
17
|
+
export type BeaconActivationData = {
|
|
18
|
+
configDigest: unknown
|
|
19
|
+
epoch: unknown
|
|
20
|
+
from: unknown
|
|
21
|
+
signature?: unknown
|
|
22
|
+
}
|
|
23
|
+
export function validateBeaconActivationData(message: BeaconActivationData): boolean
|
|
24
|
+
export function validateBeaconCommitmentData(message: BeaconCommitmentData): boolean
|
|
25
|
+
export function validateBeaconShareData(message: BeaconShareData): boolean
|
|
26
|
+
export function signBeaconCommitmentMessage(validators: string, message: BeaconCommitmentData, identity: object): Promise<string>
|
|
27
|
+
export function signBeaconShareMessage(validators: string, message: BeaconShareData, identity: object): Promise<string>
|
|
28
|
+
export function verifyBeaconCommitmentMessage(validators: string, message: BeaconCommitmentData, network: string): Promise<boolean>
|
|
29
|
+
export function verifyBeaconShareMessage(validators: string, message: BeaconShareData, network: string): Promise<boolean>
|
|
30
|
+
export function signBeaconActivationMessage(validators: string, message: BeaconActivationData, identity: object): Promise<string>
|
|
31
|
+
export function verifyBeaconActivationMessage(validators: string, message: BeaconActivationData, network: string): Promise<boolean>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type BeaconDealerContribution = {
|
|
2
|
+
commitments: Uint8Array[]
|
|
3
|
+
shares: Map<bigint, bigint>
|
|
4
|
+
}
|
|
5
|
+
export type BeaconSignatureShare = { participant: bigint; signature: Uint8Array }
|
|
6
|
+
export function createBeaconContribution(
|
|
7
|
+
participants: bigint[],
|
|
8
|
+
threshold: number,
|
|
9
|
+
randomScalar: () => bigint
|
|
10
|
+
): BeaconDealerContribution
|
|
11
|
+
export function verifyBeaconShare(participant: bigint, share: bigint, commitments: Uint8Array[]): boolean
|
|
12
|
+
export function combineBeaconShares(shares: bigint[]): bigint
|
|
13
|
+
export function deriveBeaconPublicShare(participant: bigint, commitments: Uint8Array[][]): Uint8Array
|
|
14
|
+
export function deriveBeaconGroupPublicKey(commitments: Uint8Array[][]): Uint8Array
|
|
15
|
+
export function beaconMessage(network: string, epoch: bigint, round: bigint, previousProof: Uint8Array): Uint8Array
|
|
16
|
+
export function signBeaconRound(secretShare: bigint, message: Uint8Array): Uint8Array
|
|
17
|
+
export function verifyBeaconSignatureShare(
|
|
18
|
+
signature: Uint8Array,
|
|
19
|
+
message: Uint8Array,
|
|
20
|
+
publicShare: Uint8Array
|
|
21
|
+
): boolean
|
|
22
|
+
export function reconstructBeaconSignature(shares: BeaconSignatureShare[], threshold: number): Uint8Array
|
|
23
|
+
export function verifyBeaconProof(proof: Uint8Array, message: Uint8Array, groupPublicKey: Uint8Array): boolean
|
|
24
|
+
export function beaconRandomness(proof: Uint8Array): Uint8Array
|