Exemple #1
0
 public static byte[] Encode(this ECDSAPrivateKey key)
 {
     if (key.Buffer.Length != 32)
     {
         throw new InvalidOperationException("Corrupted private key");
     }
     return(key.Buffer.ToByteArray());
 }
Exemple #2
0
 public RootProtocol(RootProtocolId id, IPublicConsensusKeySet wallet, ECDSAPrivateKey privateKey,
                     IConsensusBroadcaster broadcaster, IValidatorAttendanceRepository validatorAttendanceRepository,
                     ulong cycleDuration, bool useNewChainId) : base(wallet, id, broadcaster)
 {
     _keyPair = new EcdsaKeyPair(privateKey);
     _rootId  = id;
     _validatorAttendanceRepository = validatorAttendanceRepository;
     _cycleDuration = cycleDuration;
     _useNewChainId = useNewChainId;
 }
Exemple #3
0
 public static string ToHex(this ECDSAPrivateKey key, bool prefix = true)
 {
     return(key.Buffer.ToHex(prefix));
 }
Exemple #4
0
 public EcdsaKeyPair(ECDSAPrivateKey privateKey)
 {
     PrivateKey = privateKey;
     PublicKey  = privateKey.GetPublicKey();
 }
Exemple #5
0
 public EcdsaKeyPair(ECDSAPrivateKey privateKey, ECDSAPublicKey publicKey)
 {
     PrivateKey = privateKey;
     PublicKey  = publicKey;
 }
Exemple #6
0
 private static IEnumerable <Fr> DecryptRow(byte[] encryptedRow, ECDSAPrivateKey privateKey)
 {
     return(Crypto.Secp256K1Decrypt(privateKey.Encode(), encryptedRow)
            .Batch(Fr.ByteSize)
            .Select(b => Fr.FromBytes(b.ToArray())));
 }
Exemple #7
0
 public static ECDSAPublicKey GetPublicKey(this ECDSAPrivateKey key)
 {
     return(Crypto.ComputePublicKey(key.Encode(), true).ToPublicKey());
 }