mirror of https://github.com/nucypher/nucypher.git
exposes ferveo keypair derivation from secre randomness on the ritual power
parent
335a404a84
commit
19229ab08c
|
@ -1,3 +1,4 @@
|
|||
import ferveo_py
|
||||
import sha3
|
||||
from OpenSSL.SSL import TLSv1_2_METHOD
|
||||
from OpenSSL.crypto import X509
|
||||
|
@ -101,17 +102,15 @@ class DecryptingKeypair(Keypair):
|
|||
class RitualisticKeypair(Keypair):
|
||||
"""A keypair for Ferveo"""
|
||||
|
||||
class FerveoKey:
|
||||
"""A Keypair wrapper/shim for Ferveo to expose the public key as a callable"""
|
||||
def __init__(self):
|
||||
self.keypair = FerveoKeypair.random()
|
||||
|
||||
def public_key(self):
|
||||
return self.keypair.public_key
|
||||
|
||||
_private_key_source = FerveoKey
|
||||
_private_key_source = ferveo_py.Keypair.random
|
||||
_public_key_method = "public_key"
|
||||
|
||||
@classmethod
|
||||
def from_secure_randomness(cls, randomness: bytes) -> 'RitualisticKeypair':
|
||||
"""Create a keypair from a precomputed secure source of randomness"""
|
||||
keypair = FerveoKeypair.from_secure_randomness(randomness)
|
||||
return cls(private_key=keypair)
|
||||
|
||||
|
||||
class SigningKeypair(Keypair):
|
||||
"""
|
||||
|
|
|
@ -8,6 +8,7 @@ import stat
|
|||
import string
|
||||
import time
|
||||
from constant_sorrow.constants import KEYSTORE_LOCKED
|
||||
from ferveo_py import ferveo_py
|
||||
from mnemonic.mnemonic import Mnemonic
|
||||
from nucypher_core.umbral import SecretKeyFactory
|
||||
from pathlib import Path
|
||||
|
@ -418,7 +419,7 @@ class Keystore:
|
|||
|
||||
elif issubclass(power_class, RitualisticPower):
|
||||
keypair_class: RitualisticKeypair = power_class._keypair_class
|
||||
size = keypair_class.secure_randomness_size()
|
||||
size = ferveo_py.Keypair.secure_randomness_size()
|
||||
blob = __skf.make_secret(info)[:size]
|
||||
keypair = keypair_class.from_secure_randomness(blob)
|
||||
power = power_class(keypair=keypair, *power_args, **power_kwargs)
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import ferveo_py
|
||||
import inspect
|
||||
from eth_account._utils.signing import to_standard_signature_bytes
|
||||
from eth_typing.evm import ChecksumAddress
|
||||
from ferveo_py import (
|
||||
Keypair as FerveoKeypair,
|
||||
Transcript,
|
||||
AggregatedTranscript,
|
||||
ExternalValidator,
|
||||
DecryptionShareSimple,
|
||||
DecryptionSharePrecomputed,
|
||||
Ciphertext,
|
||||
DkgPublicParameters,
|
||||
)
|
||||
from hexbytes import HexBytes
|
||||
from nucypher_core.umbral import generate_kfrags, SecretKeyFactory, SecretKey, PublicKey
|
||||
|
@ -241,7 +239,7 @@ class DecryptingPower(KeyPairBasedPower):
|
|||
|
||||
class RitualisticPower(KeyPairBasedPower):
|
||||
_keypair_class = RitualisticKeypair
|
||||
_default_private_key_class = FerveoKeypair
|
||||
_default_private_key_class = ferveo_py.Keypair
|
||||
|
||||
not_found_error = NoRitualisticPower
|
||||
provides = ("derive_decryption_share", "generate_transcript")
|
||||
|
@ -265,7 +263,7 @@ class RitualisticPower(KeyPairBasedPower):
|
|||
threshold=threshold,
|
||||
nodes=nodes,
|
||||
aggregated_transcript=aggregated_transcript,
|
||||
keypair=self.keypair._privkey.keypair,
|
||||
keypair=self.keypair._privkey,
|
||||
ciphertext=ciphertext,
|
||||
aad=conditions,
|
||||
variant=variant
|
||||
|
|
|
@ -71,7 +71,7 @@ class Dummy: # Teacher
|
|||
operator_signature=dummy_signature,
|
||||
verifying_key=signer.verifying_key(),
|
||||
encrypting_key=SecretKey.random().public_key(),
|
||||
ferveo_public_key=bytes(Keypair.random().public_key),
|
||||
ferveo_public_key=bytes(Keypair.random().public_key()),
|
||||
certificate_der=b"not a certificate",
|
||||
host=MOCK_IP_ADDRESS,
|
||||
port=MOCK_PORT,
|
||||
|
|
Loading…
Reference in New Issue