Esempio n. 1
0
    public WabiSabiCoordinator(CoordinatorParameters parameters, IRPCClient rpc, ICoinJoinIdStore coinJoinIdStore)
    {
        Parameters = parameters;

        Warden          = new(parameters.UtxoWardenPeriod, parameters.PrisonFilePath, Config);
        ConfigWatcher   = new(parameters.ConfigChangeMonitoringPeriod, Config, () => Logger.LogInfo("WabiSabi configuration has changed."));
        CoinJoinIdStore = coinJoinIdStore;
        CoinJoinTransactionArchiver transactionArchiver = new(Path.Combine(parameters.CoordinatorDataDir, "CoinJoinTransactions"));

        CoinJoinFeeRateStatStore = CoinJoinFeeRateStatStore.LoadFromFile(parameters.CoinJoinFeeRateStatStoreFilePath, Config, rpc);
        IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinFeeRateStatStoreFilePath);
        CoinJoinFeeRateStatStore.NewStat += FeeRateStatStore_NewStat;

        var coinJoinScriptStore = CoinJoinScriptStore.LoadFromFile(parameters.CoinJoinScriptStoreFilePath);

        IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinScriptStoreFilePath);

        RoundParameterFactory roundParameterFactory = new RoundParameterFactory(Config, rpc.Network);

        Arena = new(
            parameters.RoundProgressSteppingPeriod,
            rpc.Network,
            Config,
            rpc,
            Warden.Prison,
            coinJoinIdStore,
            roundParameterFactory,
            transactionArchiver,
            coinJoinScriptStore);

        IoHelpers.EnsureContainingDirectoryExists(Parameters.CoinJoinIdStoreFilePath);
        Arena.CoinJoinBroadcast += Arena_CoinJoinBroadcast;
    }
Esempio n. 2
0
 public static Statement IssuerParametersStmt(CoordinatorParameters iparams, MAC mac, GroupElement ma)
 => new Statement(new GroupElement[, ]
 {
     // public                                             Witness terms:
     // point                     w,             wp,             x0,             x1,             ya
     { mac.V, Generators.Gw, O, mac.U, mac.T * mac.U, ma },
     { Generators.GV - iparams.I, O, O, Generators.Gx0, Generators.Gx1, Generators.Ga },
     { iparams.Cw, Generators.Gw, Generators.Gwp, O, O, O },
 });
Esempio n. 3
0
 public WabiSabiClient(
     CoordinatorParameters coordinatorParameters,
     int numberOfCredentials,
     WasabiRandom randomNumberGenerator)
 {
     RandomNumberGenerator = Guard.NotNull(nameof(randomNumberGenerator), randomNumberGenerator);
     NumberOfCredentials   = Guard.InRangeAndNotNull(nameof(numberOfCredentials), numberOfCredentials, 1, 100);
     CoordinatorParameters = Guard.NotNull(nameof(coordinatorParameters), coordinatorParameters);
     Credentials           = new CredentialPool();
 }
Esempio n. 4
0
        public CoordinatorContext(CoordinatorParameters parameters, CoordinatorDependencies dependencies, CoordinatorHooks hooks, CoordinatorConfiguration configuration)
        {
            this.parameters    = parameters;
            this.dependencies  = dependencies;
            this.hooks         = hooks;
            this.configuration = configuration;

            collection = new CoordinatorCollection();
            facts      = new CoordinatorFacts();
        }
Esempio n. 5
0
 public static Statement ShowCredentialStmt(CredentialPresentation c, GroupElement Z, CoordinatorParameters iparams)
 => new Statement(new GroupElement[, ]
 {
     // public                     Witness terms:
     // point      z               z0              t               a               r
     { Z, iparams.I, O, O, O, O },
     { c.Cx1, Generators.Gx1, Generators.Gx0, c.Cx0, O, O },
     { c.Ca, Generators.Ga, O, O, Generators.Gg, Generators.Gh },
     { c.S, O, O, O, O, Generators.Gs }
 });
Esempio n. 6
0
 public static Knowledge ShowCredential(CredentialPresentation presentation, Scalar z, Credential credential, CoordinatorParameters iparams)
 => new Knowledge(
     ShowCredentialStmt(presentation, z * iparams.I, iparams),
     new ScalarVector(z, (credential.Mac.T * z).Negate(), credential.Mac.T, credential.Amount, credential.Randomness));
Esempio n. 7
0
 public static LinearRelation.Statement CreateStatement(CoordinatorParameters coordinatorParameters, GroupElement V, GroupElement Ma, Scalar t) =>
 new LinearRelation.Statement(
     new GroupElementVector(coordinatorParameters.Cw, Generators.GV - coordinatorParameters.I, V)
     .Zip(ProofOfParametersGenerators(MAC.GenerateU(t), Ma, t), (publicPoint, groupElement) => new Equation(publicPoint, groupElement)));
Esempio n. 8
0
 private static WabiSabiCoordinator CreateWabiSabiCoordinator(CoordinatorParameters coordinatorParameters)
 => new(coordinatorParameters, NewMockRpcClient(), new CoinJoinIdStore(), new CoinJoinScriptStore());