Complete clearing service impl
This commit is contained in:
parent
f961c2fdbc
commit
3a713c38df
2 changed files with 24 additions and 20 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -835,7 +835,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cw-tee-mtcs"
|
name = "cw-tee-mtcs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#3382463b74411fd873a927e1d26b09c35b339753"
|
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#48508d739427bd3f2a983c8e8d4c6eb2e677aff2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmwasm-schema",
|
"cosmwasm-schema",
|
||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
|
@ -1416,7 +1416,7 @@ dependencies = [
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http",
|
"http",
|
||||||
"indexmap 2.2.3",
|
"indexmap 2.2.4",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
@ -1452,9 +1452,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60"
|
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
|
@ -1630,9 +1630,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.2.3"
|
version = "2.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
|
checksum = "967d6dd42f16dbf0eb8040cb9e477933562684d3918f7d253f2ff9087fb3e7a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.14.3",
|
"hashbrown 0.14.3",
|
||||||
|
@ -2251,7 +2251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
|
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fixedbitset",
|
"fixedbitset",
|
||||||
"indexmap 2.2.3",
|
"indexmap 2.2.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2455,7 +2455,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quartz-cw"
|
name = "quartz-cw"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#3382463b74411fd873a927e1d26b09c35b339753"
|
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#48508d739427bd3f2a983c8e8d4c6eb2e677aff2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmwasm-schema",
|
"cosmwasm-schema",
|
||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
|
@ -2530,7 +2530,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quartz-tee-ra"
|
name = "quartz-tee-ra"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#3382463b74411fd873a927e1d26b09c35b339753"
|
source = "git+ssh://git@github.com/informalsystems/bisenzone-cw-mvp.git?branch=hu55a1n1/11-use-quartz#48508d739427bd3f2a983c8e8d4c6eb2e677aff2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmwasm-schema",
|
"cosmwasm-schema",
|
||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
|
|
|
@ -50,20 +50,22 @@ where
|
||||||
serde_json::from_str(&message).map_err(|e| Status::invalid_argument(e.to_string()))?;
|
serde_json::from_str(&message).map_err(|e| Status::invalid_argument(e.to_string()))?;
|
||||||
|
|
||||||
let sk = self.sk.lock().unwrap();
|
let sk = self.sk.lock().unwrap();
|
||||||
let obligations: Vec<_> = obligations_enc
|
let (digests, obligations): (Vec<RawHash>, Vec<SimpleObligation<HexBinary, i64>>) =
|
||||||
.into_values()
|
obligations_enc
|
||||||
.map(|ciphertext| {
|
.into_iter()
|
||||||
let o = decrypt(&sk.as_ref().unwrap().to_bytes(), &ciphertext).unwrap();
|
.map(|(digest, ciphertext)| {
|
||||||
serde_json::from_slice::<SimpleObligation<HexBinary, i64>>(&o).unwrap()
|
let o = decrypt(&sk.as_ref().unwrap().to_bytes(), &ciphertext).unwrap();
|
||||||
})
|
(digest, serde_json::from_slice(&o).unwrap())
|
||||||
.collect();
|
})
|
||||||
|
.unzip();
|
||||||
|
|
||||||
let mut mtcs = ComplexIdMtcs::wrapping(DefaultMtcs::new(PrimalDual::default()));
|
let mut mtcs = ComplexIdMtcs::wrapping(DefaultMtcs::new(PrimalDual::default()));
|
||||||
let setoffs: Vec<SimpleSetoff<HexBinary, i64>> = mtcs.run(obligations).unwrap();
|
let setoffs: Vec<SimpleSetoff<HexBinary, i64>> = mtcs.run(obligations).unwrap();
|
||||||
|
|
||||||
let setoffs_enc: Vec<HexBinary> = setoffs
|
let setoffs_enc: BTreeMap<RawHash, RawCipherText> = setoffs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|so| {
|
.zip(digests)
|
||||||
|
.flat_map(|(so, digest)| {
|
||||||
let debtor_pk = VerifyingKey::from_sec1_bytes(&so.debtor).unwrap();
|
let debtor_pk = VerifyingKey::from_sec1_bytes(&so.debtor).unwrap();
|
||||||
let creditor_pk = VerifyingKey::from_sec1_bytes(&so.creditor).unwrap();
|
let creditor_pk = VerifyingKey::from_sec1_bytes(&so.creditor).unwrap();
|
||||||
|
|
||||||
|
@ -71,9 +73,11 @@ where
|
||||||
let so_debtor = encrypt(&debtor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap();
|
let so_debtor = encrypt(&debtor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap();
|
||||||
let so_creditor = encrypt(&creditor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap();
|
let so_creditor = encrypt(&creditor_pk.to_sec1_bytes(), so_ser.as_bytes()).unwrap();
|
||||||
|
|
||||||
[so_debtor, so_creditor]
|
[
|
||||||
|
(digest.clone(), so_debtor.into()),
|
||||||
|
(digest, so_creditor.into()),
|
||||||
|
]
|
||||||
})
|
})
|
||||||
.map(Into::into)
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let message = serde_json::to_string(&SubmitSetoffsMsg { setoffs_enc }).unwrap();
|
let message = serde_json::to_string(&SubmitSetoffsMsg { setoffs_enc }).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue