Example #1
0
 public static byte[] Encode(this ECDSAPrivateKey key)
 {
     if (key.Buffer.Length != 32)
     {
         throw new InvalidOperationException("Corrupted private key");
     }
     return(key.Buffer.ToByteArray());
 }
Example #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;
 }
Example #3
0
 public static string ToHex(this ECDSAPrivateKey key, bool prefix = true)
 {
     return(key.Buffer.ToHex(prefix));
 }
Example #4
0
 public EcdsaKeyPair(ECDSAPrivateKey privateKey)
 {
     PrivateKey = privateKey;
     PublicKey  = privateKey.GetPublicKey();
 }
Example #5
0
 public EcdsaKeyPair(ECDSAPrivateKey privateKey, ECDSAPublicKey publicKey)
 {
     PrivateKey = privateKey;
     PublicKey  = publicKey;
 }
Example #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())));
 }
Example #7
0
 public static ECDSAPublicKey GetPublicKey(this ECDSAPrivateKey key)
 {
     return(Crypto.ComputePublicKey(key.Encode(), true).ToPublicKey());
 }