wallet.rs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2022 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. // use log::debug;
  19. // use rand::rngs::OsRng;
  20. // use halo2_proofs::circuit::Value;
  21. // use pasta_curves::pallas;
  22. // use darkfi::{
  23. // crypto::{
  24. // keypair::{PublicKey, SecretKey},
  25. // Proof,
  26. // },
  27. // zk::vm::{Witness, ZkCircuit},
  28. // };
  29. // use crate::{
  30. // contract::example_contract::{foo::validate::CallData, CONTRACT_ID},
  31. // util::{FuncCall, ZkContractInfo, ZkContractTable},
  32. // };
  33. // pub struct Foo {
  34. // pub a: u64,
  35. // pub b: u64,
  36. // }
  37. // pub struct Builder {
  38. // pub foo: Foo,
  39. // pub signature_secret: SecretKey,
  40. // }
  41. // impl Builder {
  42. // pub fn build(self, zk_bins: &ZkContractTable) -> FuncCall {
  43. // debug!(target: "example_contract::foo::wallet::Builder", "build()");
  44. // let mut proofs = vec![];
  45. // let zk_info = zk_bins.lookup(&"example-foo".to_string()).unwrap();
  46. // let zk_info = if let ZkContractInfo::Binary(info) = zk_info {
  47. // info
  48. // } else {
  49. // panic!("Not binary info")
  50. // };
  51. // let zk_bin = zk_info.bincode.clone();
  52. // let prover_witnesses = vec![
  53. // Witness::Base(Value::known(pallas::Base::from(self.foo.a))),
  54. // Witness::Base(Value::known(pallas::Base::from(self.foo.b))),
  55. // ];
  56. // let a = pallas::Base::from(self.foo.a);
  57. // let b = pallas::Base::from(self.foo.b);
  58. // let c = a + b;
  59. // let public_inputs = vec![c];
  60. // let circuit = ZkCircuit::new(prover_witnesses, zk_bin);
  61. // debug!(target: "example_contract::foo::wallet::Builder", "input_proof Proof::create()");
  62. // let proving_key = &zk_info.proving_key;
  63. // let input_proof = Proof::create(proving_key, &[circuit], &public_inputs, &mut OsRng)
  64. // .expect("Example::foo() proving error!)");
  65. // proofs.push(input_proof);
  66. // let signature_public = PublicKey::from_secret(self.signature_secret);
  67. // let call_data = CallData { public_value: c, signature_public };
  68. // FuncCall {
  69. // contract_id: *CONTRACT_ID,
  70. // func_id: *super::FUNC_ID,
  71. // call_data: Box::new(call_data),
  72. // proofs,
  73. // }
  74. // }
  75. // }