Skip to content

Commit d896b55

Browse files
authored
Merge pull request #199 from input-output-hk/pass_stm
Pass on stm module
2 parents f20638e + cf26c38 commit d896b55

File tree

20 files changed

+407
-1729
lines changed

20 files changed

+407
-1729
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,6 @@ jobs:
139139
run: |
140140
set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-core.xml)
141141
142-
- name: Set up Clang
143-
uses: egor-tensin/setup-clang@v1
144-
with:
145-
version: latest
146-
platform: x64
147-
148-
- name: Install gtest manually
149-
run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
150-
151-
- name: Build C test
152-
run: clang -x c++ tests.c stms.c -g -o tests -L ../target/release -lmithril -lpthread -lstdc++ -lgtest -lgtest_main
153-
working-directory: mithril-core/c-tests
154-
155-
- name: Run C test
156-
run: LD_LIBRARY_PATH=../target/release ./tests --gtest_output=xml:test-results-ctest-mithril-core.xml
157-
working-directory: mithril-core/c-tests
158142
159143
- name: Upload Unit Test Results
160144
if: always()

demo/protocol-demo/src/demonstrator.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ impl Party {
165165
/// Verify a certificate
166166
pub fn verify_message(&self, message: &Bytes) -> Result<(), String> {
167167
match self.get_aggregate(message) {
168-
Some(msig) => match self.clerk.as_ref().unwrap().verify_msig(msig, message) {
168+
Some(msig) => match msig.verify(
169+
message,
170+
&self.clerk.as_ref().unwrap().compute_avk(),
171+
&self.params.unwrap(),
172+
) {
169173
Ok(_) => {
170174
println!(
171175
"Party #{}: aggregate signature successfully verified for {}!",
@@ -253,7 +257,11 @@ impl Verifier {
253257
message: &Bytes,
254258
msig: &ProtocolMultiSignature,
255259
) -> Result<(), String> {
256-
match self.clerk.as_ref().unwrap().verify_msig(msig, message) {
260+
match msig.verify(
261+
message,
262+
&self.clerk.as_ref().unwrap().compute_avk(),
263+
&self.params.unwrap(),
264+
) {
257265
Ok(_) => {
258266
println!(
259267
"Verifier: aggregate signature successfully verified for {}!",

mithril-aggregator/src/http_server.rs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

mithril-aggregator/src/multi_signer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ impl MultiSigner for MultiSignerImpl {
241241
.get_current_message()
242242
.ok_or_else(ProtocolError::UnavailableMessage)?;
243243
let clerk = self.clerk();
244-
match clerk.verify_sig(signature, message) {
244+
let avk = clerk.compute_avk();
245+
match signature.verify(&self.protocol_parameters.unwrap(), &avk, message) {
245246
Ok(_) => {
246247
// Register single signature
247248
self.single_signatures

mithril-client/src/verifier.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl VerifierImpl {
4545
&self,
4646
signers_with_stakes: &[entities::SignerWithStake],
4747
protocol_parameters: &entities::ProtocolParameters,
48-
) -> Result<ProtocolClerk, String> {
48+
) -> Result<ProtocolClerk, ProtocolError> {
4949
let stakes = signers_with_stakes
5050
.iter()
5151
.map(|signer| {
@@ -87,13 +87,16 @@ impl Verifier for VerifierImpl {
8787
protocol_parameters: &entities::ProtocolParameters,
8888
) -> Result<(), ProtocolError> {
8989
debug!("Verify multi signature for {:?}", message);
90-
let clerk = self.create_clerk(signers_with_stakes, protocol_parameters);
9190
let multi_signature: ProtocolMultiSignature =
9291
key_decode_hex(multi_signature).map_err(ProtocolError::VerifyMultiSignatureError)?;
93-
clerk
94-
.as_ref()
95-
.unwrap()
96-
.verify_msig(&multi_signature, message)
92+
multi_signature
93+
.verify(
94+
message,
95+
&self
96+
.create_clerk(signers_with_stakes, protocol_parameters)?
97+
.compute_avk(),
98+
&protocol_parameters.to_owned().into(),
99+
)
97100
.map_err(|e| ProtocolError::VerifyMultiSignatureError(e.to_string()))
98101
}
99102
}

mithril-common/src/crypto_helper/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use mithril::key_reg::KeyReg;
22
use mithril::stm::{
3-
Index, PartyId, Stake, StmClerk, StmInitializer, StmMultiSig, StmParameters, StmSig, StmSigner,
4-
StmVerificationKey,
3+
Index, PartyId, Stake, StmAggrSig, StmClerk, StmInitializer, StmParameters, StmSig, StmSigner,
4+
StmVerificationKeyPoP,
55
};
66

77
use super::super::entities;
@@ -20,8 +20,8 @@ pub type ProtocolInitializer = StmInitializer;
2020
pub type ProtocolClerk = StmClerk<D>;
2121
pub type ProtocolKeyRegistration = KeyReg;
2222
pub type ProtocolSingleSignature = StmSig<D>;
23-
pub type ProtocolMultiSignature = StmMultiSig<D>;
24-
pub type ProtocolSignerVerificationKey = StmVerificationKey;
23+
pub type ProtocolMultiSignature = StmAggrSig<D>;
24+
pub type ProtocolSignerVerificationKey = StmVerificationKeyPoP;
2525

2626
impl From<ProtocolParameters> for entities::ProtocolParameters {
2727
fn from(other: ProtocolParameters) -> Self {

mithril-core/benches/stm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ where
178178
let clerk = StmClerk::from_signer(&party_dummy);
179179
let msig = clerk.aggregate(&sigs, &msg).unwrap();
180180
group.bench_function("Verification", |b| {
181-
b.iter(|| clerk.verify_msig(&msig, &msg).is_ok())
181+
b.iter(|| msig.verify(&msg, &clerk.compute_avk(), &params).is_ok())
182182
});
183183
}
184184

mithril-core/build.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

mithril-core/c-tests/README.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)