Exemplo n.º 1
0
        public async Task <ArenaResponse <Guid> > RegisterInputAsync(
            uint256 roundId,
            OutPoint outPoint,
            Key key,
            CancellationToken cancellationToken)
        {
            var ownershipProof = OwnershipProof.GenerateCoinJoinInputProof(
                key,
                new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundId));

            var zeroAmountCredentialRequestData = AmountCredentialClient.CreateRequestForZeroAmount();
            var zeroVsizeCredentialRequestData  = VsizeCredentialClient.CreateRequestForZeroAmount();

            var inputRegistrationResponse = await RequestHandler.RegisterInputAsync(
                new InputRegistrationRequest(
                    roundId,
                    outPoint,
                    ownershipProof,
                    zeroAmountCredentialRequestData.CredentialsRequest,
                    zeroVsizeCredentialRequestData.CredentialsRequest),
                cancellationToken).ConfigureAwait(false);

            var realAmountCredentials = AmountCredentialClient.HandleResponse(inputRegistrationResponse.AmountCredentials, zeroAmountCredentialRequestData.CredentialsResponseValidation);
            var realVsizeCredentials  = VsizeCredentialClient.HandleResponse(inputRegistrationResponse.VsizeCredentials, zeroVsizeCredentialRequestData.CredentialsResponseValidation);

            return(new(inputRegistrationResponse.AliceId, realAmountCredentials, realVsizeCredentials));
        }
Exemplo n.º 2
0
        private static uint256 CalculateHash(Coin coin, BitcoinSecret bitcoinSecret, uint256 roundId)
        {
            var ownershipProof = OwnershipProof.GenerateCoinJoinInputProof(
                bitcoinSecret.PrivateKey,
                new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundId));

            return(new Alice(coin, ownershipProof).Id);
        }
Exemplo n.º 3
0
        public static InputRoundSignaturePair CreateInputRoundSignaturePair(Key?key = null, uint256?roundHash = null)
        {
            var rh       = roundHash ?? BitcoinFactory.CreateUint256();
            var outpoint = BitcoinFactory.CreateOutPoint();
            var coinJoinInputCommitmentData = new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", rh);

            var signingKey = key ?? new();

            return(new InputRoundSignaturePair(
                       outpoint,
                       OwnershipProof.GenerateCoinJoinInputProof(signingKey, coinJoinInputCommitmentData).ToBytes()));
        }
Exemplo n.º 4
0
    public OwnershipProof GetOwnershipProof(IDestination destination, CoinJoinInputCommitmentData commitmentData)
    {
        var secret = GetBitcoinSecret(destination.ScriptPubKey);

        var masterKey = KeyManager.GetMasterExtKey(Kitchen.SaltSoup()).PrivateKey;
        var identificationMasterKey = Slip21Node.FromSeed(masterKey.ToBytes());
        var identificationKey       = identificationMasterKey.DeriveChild("SLIP-0019").DeriveChild("Ownership identification key").Key;

        var signingKey     = secret.PrivateKey;
        var ownershipProof = OwnershipProof.GenerateCoinJoinInputProof(
            signingKey,
            new OwnershipIdentifier(identificationKey, destination.ScriptPubKey),
            commitmentData);

        return(ownershipProof);
    }
Exemplo n.º 5
0
 static byte[] GenerateOwnershipProof(Key key, uint256 roundHash) => OwnershipProof.GenerateCoinJoinInputProof(
     key,
     new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundHash)).ToBytes();
 /// <remarks>Each instance represents the same proof but a new object instance.</remarks>
 public static OwnershipProof CreateOwnershipProof(Key key, uint256 roundHash)
 => OwnershipProof.GenerateCoinJoinInputProof(
     key,
     new OwnershipIdentifier(key, key.PubKey.WitHash.ScriptPubKey),
     new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundHash));