-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to nucypher-core@0.11.0
#250
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
DkgPublicKey, | ||
EthereumAddress, | ||
FerveoPublicKey, | ||
FerveoVariant, | ||
SharedSecret, | ||
Validator, | ||
ValidatorMessage, | ||
|
@@ -17,22 +18,15 @@ import { DkgCoordinatorAgent, DkgRitualState } from './agents/coordinator'; | |
import { ChecksumAddress } from './types'; | ||
import { bytesEquals, fromHexString, objectEquals } from './utils'; | ||
|
||
// TODO: Expose from @nucypher/nucypher-core | ||
export enum FerveoVariant { | ||
Simple = 0, | ||
Precomputed = 1, | ||
} | ||
|
||
export function getVariantClass( | ||
variant: FerveoVariant | ||
): typeof DecryptionShareSimple | typeof DecryptionSharePrecomputed { | ||
switch (variant) { | ||
case FerveoVariant.Simple: | ||
return DecryptionShareSimple; | ||
case FerveoVariant.Precomputed: | ||
return DecryptionSharePrecomputed; | ||
default: | ||
throw new Error(`Invalid FerveoVariant: ${variant}`); | ||
if (variant.equals(FerveoVariant.simple)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity: why has this been changed from switch conditionals to If/ else if? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementing comparison for WASM objects is tricky ( So previously we sort of got away without doing all of that because Now that the Perhaps there is a better way to do that, like somehow implementing a native There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got it. Thanks for the elaborate explanation, Piotr 🙌 |
||
return DecryptionShareSimple; | ||
} else if (variant.equals(FerveoVariant.precomputed)) { | ||
return DecryptionSharePrecomputed; | ||
} else { | ||
throw new Error(`Invalid FerveoVariant: ${variant}`); | ||
} | ||
} | ||
|
||
|
@@ -41,13 +35,12 @@ export function getCombineDecryptionSharesFunction( | |
): ( | ||
shares: DecryptionShareSimple[] | DecryptionSharePrecomputed[] | ||
) => SharedSecret { | ||
switch (variant) { | ||
case FerveoVariant.Simple: | ||
return combineDecryptionSharesSimple; | ||
case FerveoVariant.Precomputed: | ||
return combineDecryptionSharesPrecomputed; | ||
default: | ||
throw new Error(`Invalid FerveoVariant: ${variant}`); | ||
if (variant.equals(FerveoVariant.simple)) { | ||
return combineDecryptionSharesSimple; | ||
} else if (variant.equals(FerveoVariant.precomputed)) { | ||
return combineDecryptionSharesPrecomputed; | ||
} else { | ||
throw new Error(`Invalid FerveoVariant: ${variant}`); | ||
} | ||
} | ||
|
||
|
@@ -209,12 +202,12 @@ export class DkgClient { | |
const participantPublicKeys: Record<string, FerveoPublicKey> = { | ||
'0x210eeAC07542F815ebB6FD6689637D8cA2689392': FerveoPublicKey.fromBytes( | ||
fromHexString( | ||
'6000000000000000ace9d7567b26dafc512b2303cfdaa872850c62b100078ddeaabf8408c7308b3a43dfeb88375c21ef63230fb4008ce7e908764463c6765e556f9b03009eb1757d179eaa26bf875332807cc070d62a385ed2e66e09f4f4766451da12779a09036e' | ||
'ace9d7567b26dafc512b2303cfdaa872850c62b100078ddeaabf8408c7308b3a43dfeb88375c21ef63230fb4008ce7e908764463c6765e556f9b03009eb1757d179eaa26bf875332807cc070d62a385ed2e66e09f4f4766451da12779a09036e' | ||
) | ||
), | ||
'0xb15d5A4e2be34f4bE154A1b08a94Ab920FfD8A41': FerveoPublicKey.fromBytes( | ||
fromHexString( | ||
'60000000000000008b373fdb6b43e9dca028bd603c2bf90f0e008ec83ff217a8d7bc006b585570e6ab1ce761bad0e21c1aed1363286145f61134ed0ab53f4ebaa05036396c57f6e587f33d49667c1003cd03b71ad651b09dd4791bc631eaef93f1b313bbee7bd63a' | ||
'8b373fdb6b43e9dca028bd603c2bf90f0e008ec83ff217a8d7bc006b585570e6ab1ce761bad0e21c1aed1363286145f61134ed0ab53f4ebaa05036396c57f6e587f33d49667c1003cd03b71ad651b09dd4791bc631eaef93f1b313bbee7bd63a' | ||
) | ||
), | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be updated after
nucypher-core@0.11.0
release