Do multisig call after verification
This commit is contained in:
Generated
+104
-8
@@ -80,6 +80,7 @@ dependencies = [
|
||||
"bip39",
|
||||
"coconut-interface",
|
||||
"credentials",
|
||||
"cw3-flex-multisig",
|
||||
"network-defaults",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1005,9 +1006,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cosmwasm-crypto"
|
||||
version = "1.0.0-beta4"
|
||||
version = "1.0.0-beta5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f903ebbabc0d4880dbc76148efb8be8fc29fa4bf294c440c3d70da1c8bcafff7"
|
||||
checksum = "8904127a5b9e325ef5d6b2b3f997dcd74943cd35097139b1a4d15b1b6bccae66"
|
||||
dependencies = [
|
||||
"digest 0.9.0",
|
||||
"ed25519-zebra",
|
||||
@@ -1018,18 +1019,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cosmwasm-derive"
|
||||
version = "1.0.0-beta4"
|
||||
version = "1.0.0-beta5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "832bebef577ecb394603de8e2bf0de429b74aa364e17dec18e15ce37e71b0cae"
|
||||
checksum = "a14364ac4d9d085867929d0cf3e94b1d2100121ce02c33c72961406830002613"
|
||||
dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cosmwasm-std"
|
||||
version = "1.0.0-beta4"
|
||||
version = "1.0.0-beta5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6238c45840cc9de5a39f0f619e3a4f7c38c5d2c6ac9e3e4d72751ee045e6d7da"
|
||||
checksum = "e2ece12e5bbde434b93937d7b2107e6291f11d69ffa72398c50e8bab41d451d3"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"cosmwasm-crypto",
|
||||
@@ -1339,6 +1340,99 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw-storage-plus"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c087ff98fb0475db4c2b5298a5fd12b2848d2854b39d1115d930ee6da24d1eed"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"schemars",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw-utils"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3396c7aff5a0e3fb6dcc6cc89f56862c1d212b40d93ed725a6962955b1887ff"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"schemars",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw2"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f8a6500c396e33f6a7b05d35a5124eb3e394cdb6ca901f7e88332870407896c"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus 0.12.1",
|
||||
"schemars",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw3"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "017b6263414c58081cea97626f4d8da2dc8f7267337bba0eb5770260d26251e0"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"cw-utils",
|
||||
"schemars",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw3-fixed-multisig"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "949d65e60dbe8a24fc58b6b33143328af0abcc72e108a7ff80d2f3f8cabdf63b"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus 0.12.1",
|
||||
"cw-utils",
|
||||
"cw2",
|
||||
"cw3",
|
||||
"schemars",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw3-flex-multisig"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "297fe0521cf453ed58b582262cdb045862f126eb9390432e5689774badcfa370"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus 0.12.1",
|
||||
"cw-utils",
|
||||
"cw2",
|
||||
"cw3",
|
||||
"cw3-fixed-multisig",
|
||||
"cw4",
|
||||
"schemars",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cw4"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f22da7845e99e5a277523d61c19bda3171ec3dd1084b9ca6ebac6b2fd0cdf084"
|
||||
dependencies = [
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus 0.12.1",
|
||||
"schemars",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.10.2"
|
||||
@@ -3999,6 +4093,8 @@ dependencies = [
|
||||
"console-subscriber",
|
||||
"credentials",
|
||||
"crypto",
|
||||
"cw3",
|
||||
"cw3-flex-multisig",
|
||||
"dirs",
|
||||
"dotenv",
|
||||
"futures",
|
||||
@@ -7731,7 +7827,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus",
|
||||
"cw-storage-plus 0.11.1",
|
||||
"mixnet-contract-common",
|
||||
"schemars",
|
||||
"serde",
|
||||
@@ -7745,7 +7841,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"cosmwasm-std",
|
||||
"cw-storage-plus",
|
||||
"cw-storage-plus 0.11.1",
|
||||
"mixnet-contract-common",
|
||||
"schemars",
|
||||
"serde",
|
||||
|
||||
@@ -15,6 +15,7 @@ build = "src/build.rs"
|
||||
tauri-build = { version = "1.0.0-beta.2" }
|
||||
|
||||
[dependencies]
|
||||
cw3-flex-multisig = "0.12.1"
|
||||
bip39 = "1.0.1"
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -183,7 +183,7 @@ async fn verify_credential(
|
||||
state.voucher_info.to_byte_vec(),
|
||||
];
|
||||
|
||||
let credential = Credential::new(
|
||||
let mut credential = Credential::new(
|
||||
state.n_attributes,
|
||||
theta.clone(),
|
||||
public_attributes_bytes,
|
||||
@@ -191,6 +191,7 @@ async fn verify_credential(
|
||||
.signatures
|
||||
.get(idx)
|
||||
.ok_or("Got invalid signature idx")?,
|
||||
0,
|
||||
);
|
||||
println!("Using verification key: {:?}", verification_key.to_bs58());
|
||||
let local_check = credential.verify(&verification_key);
|
||||
@@ -198,6 +199,51 @@ async fn verify_credential(
|
||||
if !local_check {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let mnemonic = Mnemonic::from_str("sun surge soon stomach flavor country gorilla dress oblige stamp attract hip soldier agree steel prize nuclear know enjoy arm bargain always theme matter").unwrap();
|
||||
let nymd_url = Url::from_str("http://127.0.0.1:26657").unwrap();
|
||||
let nymd_client = NymdClient::connect_with_mnemonic(
|
||||
network_defaults::all::Network::SANDBOX,
|
||||
nymd_url.as_ref(),
|
||||
None,
|
||||
None,
|
||||
AccountId::from_str("nymt14hj2tavq8fpesdwxxcu44rty3hh90vhuysqrsr").ok(),
|
||||
mnemonic,
|
||||
None,
|
||||
)
|
||||
.expect("Could not create nymd client");
|
||||
let req = cw3_flex_multisig::msg::ExecuteMsg::Propose {
|
||||
title: "Spend coconut".to_string(),
|
||||
description: "Propose to spend a coconut cred".to_string(),
|
||||
msgs: vec![],
|
||||
latest: None,
|
||||
};
|
||||
let tx = nymd_client
|
||||
.execute(
|
||||
&AccountId::from_str("nymt1qwlgtx52gsdu7dtp0cekka5zehdl0uj3vqx3jd").unwrap(),
|
||||
&req,
|
||||
Default::default(),
|
||||
"",
|
||||
vec![],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let event = tx.logs[0]
|
||||
.events
|
||||
.iter()
|
||||
.find(|event| event.ty == "wasm")
|
||||
.unwrap();
|
||||
let proposal_id = u64::from_str(
|
||||
&event
|
||||
.attributes
|
||||
.iter()
|
||||
.find(|attr| attr.key == "proposal_id")
|
||||
.unwrap()
|
||||
.value,
|
||||
)
|
||||
.unwrap();
|
||||
println!("Got proposal id {}", proposal_id);
|
||||
credential.set_proposal_id(proposal_id);
|
||||
let remote_check = verify_credential_remote(&parsed_urls, credential)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct Log {
|
||||
// and launchpad cosmos validator was setting it to what essentially is just the raw version of what
|
||||
// we received (and we don't care about launchpad, we, as the time of writing this, work on the stargate)
|
||||
// log: String,
|
||||
events: Vec<cosmwasm_std::Event>,
|
||||
pub events: Vec<cosmwasm_std::Event>,
|
||||
}
|
||||
|
||||
/// Searches in logs for the first event of the given event type and in that event
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use getset::{CopyGetters, Getters};
|
||||
use getset::{CopyGetters, Getters, Setters};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use nymcoconut::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, Getters, CopyGetters, Clone)]
|
||||
#[derive(Serialize, Deserialize, Getters, CopyGetters, Setters, Clone)]
|
||||
pub struct Credential {
|
||||
#[getset(get = "pub")]
|
||||
n_params: u32,
|
||||
@@ -15,6 +15,8 @@ pub struct Credential {
|
||||
public_attributes: Vec<Vec<u8>>,
|
||||
#[getset(get = "pub")]
|
||||
signature: Signature,
|
||||
#[getset(get = "pub", set = "pub")]
|
||||
proposal_id: u64,
|
||||
}
|
||||
impl Credential {
|
||||
pub fn new(
|
||||
@@ -22,12 +24,14 @@ impl Credential {
|
||||
theta: Theta,
|
||||
public_attributes: Vec<Vec<u8>>,
|
||||
signature: &Signature,
|
||||
proposal_id: u64,
|
||||
) -> Credential {
|
||||
Credential {
|
||||
n_params,
|
||||
theta,
|
||||
public_attributes,
|
||||
signature: *signature,
|
||||
proposal_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,5 +212,6 @@ pub fn prepare_credential_for_spending(
|
||||
theta,
|
||||
public_attributes,
|
||||
signature,
|
||||
0,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ rust-version = "1.56"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
cw3-flex-multisig = "0.12.1"
|
||||
cw3 = "0.12.1"
|
||||
bip39 = "1.0.1"
|
||||
clap = "2.33.0"
|
||||
dirs = "3.0"
|
||||
|
||||
@@ -9,6 +9,7 @@ use coconut_interface::{
|
||||
VerificationKeyResponse, VerifyCredentialResponse,
|
||||
};
|
||||
use config::defaults::VALIDATOR_API_VERSION;
|
||||
use cw3_flex_multisig::msg::ExecuteMsg;
|
||||
use getset::{CopyGetters, Getters};
|
||||
use rocket::fairing::AdHoc;
|
||||
use rocket::serde::json::Json;
|
||||
@@ -152,6 +153,42 @@ pub async fn post_verify_credential(
|
||||
let response = verify_credential_body
|
||||
.0
|
||||
.verify(&aggregated_verification_key);
|
||||
if !response {
|
||||
return Json(VerifyCredentialResponse { response });
|
||||
}
|
||||
let mnemonic = if std::env::var("ROCKET_PORT") == Ok("8081".to_string()) {
|
||||
"have armor behind appear labor choose fire erase arrive slice mother acid second rely exhibit grief soul super record useless antique excite ocean walnut"
|
||||
} else if std::env::var("ROCKET_PORT") == Ok("8082".to_string()) {
|
||||
"inner luggage start square fabric ritual cereal engine winner tiny exile frozen end cherry loan humble laundry desk blur vicious word amount remove praise"
|
||||
} else {
|
||||
"hat pulse impulse prosper name rose auction grape stone leader book provide discover exchange drift story parent barely novel giggle deposit dizzy recipe where"
|
||||
};
|
||||
let mnemonic = Mnemonic::from_str(mnemonic).unwrap();
|
||||
let nymd_url = Url::from_str("http://127.0.0.1:26657").unwrap();
|
||||
let nymd_client = NymdClient::connect_with_mnemonic(
|
||||
config::defaults::all::Network::SANDBOX,
|
||||
nymd_url.as_ref(),
|
||||
None,
|
||||
None,
|
||||
AccountId::from_str("nymt14hj2tavq8fpesdwxxcu44rty3hh90vhuysqrsr").ok(),
|
||||
mnemonic,
|
||||
None,
|
||||
)
|
||||
.expect("Could not create nymd client");
|
||||
let req = ExecuteMsg::Vote {
|
||||
proposal_id: *verify_credential_body.0.proposal_id(),
|
||||
vote: cw3::Vote::Yes,
|
||||
};
|
||||
nymd_client
|
||||
.execute(
|
||||
&AccountId::from_str("nymt1qwlgtx52gsdu7dtp0cekka5zehdl0uj3vqx3jd").unwrap(),
|
||||
&req,
|
||||
Default::default(),
|
||||
"",
|
||||
vec![],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("Sending response: {}", response);
|
||||
Json(VerifyCredentialResponse { response })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user