public void Signature(byte[] privatekey) { ECKey ec_key = ECKey.FromPrivateKey(privatekey); ECDSASignature signature = ec_key.Sign(GetRawHash().Hash); this.transaction.Signature.Add(ByteString.CopyFrom(signature.ToByteArray())); }
public void AddSignature(byte[] privatekey, AccountStore account_store) { Transaction.Types.Contract contract = this.transaction.RawData.Contract[0]; byte[] owner = GetOwner(contract); int permission_id = contract.PermissionId; AccountCapsule account = account_store.Get(owner); if (account == null) { throw new PermissionException("Account is not exist."); } Permission permission = account.GetPermissionById(permission_id); if (permission == null) { throw new PermissionException("Permission is not exist"); } if (permission_id != 0) { if (permission.Type != Permission.Types.PermissionType.Active) { throw new PermissionException("Permission type is error"); } if (Wallet.CheckPermissionOperations(permission, contract)) { throw new PermissionException("Invalid permission"); } } List <ByteString> approves = new List <ByteString>(); ECKey ec_key = ECKey.FromPrivateKey(privatekey); byte[] address = Wallet.PublickKeyToAddress(ec_key.PublicKey); if (this.transaction.Signature.Count > 0) { CheckWeight(permission, new List <ByteString>(this.transaction.Signature), this.GetRawHash().Hash, approves); if (approves.Contains(ByteString.CopyFrom(address))) { throw new PermissionException(Wallet.AddressToBase58(address) + "had signed!"); } } long weight = GetWeight(permission, address); if (weight == 0) { throw new PermissionException( privatekey.ToHexString() + " address is " + Wallet.AddressToBase58(address) + "but it is not contained of permission."); } ECDSASignature signature = ec_key.Sign(this.GetRawHash().Hash); this.transaction.Signature.Add(ByteString.CopyFrom(signature.ToByteArray())); }
public void Sign(byte[] privatekey) { ECKey ec_key = ECKey.FromPrivateKey(privatekey); ECDSASignature signature = ec_key.Sign(this.GetRawHash().Hash); this.block.BlockHeader.WitnessSignature = ByteString.CopyFrom(signature.ToByteArray()); }