Skip to content

Pass on stm module #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ jobs:
run: |
set -o pipefail && cargo test --release -- -Z unstable-options --format json --report-time | tee >(cargo2junit > test-results-mithril-core.xml)

- name: Set up Clang
uses: egor-tensin/setup-clang@v1
with:
version: latest
platform: x64

- name: Install gtest manually
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

- name: Build C test
run: clang -x c++ tests.c stms.c -g -o tests -L ../target/release -lmithril -lpthread -lstdc++ -lgtest -lgtest_main
working-directory: mithril-core/c-tests

- name: Run C test
run: LD_LIBRARY_PATH=../target/release ./tests --gtest_output=xml:test-results-ctest-mithril-core.xml
working-directory: mithril-core/c-tests

- name: Upload Unit Test Results
if: always()
Expand Down
12 changes: 10 additions & 2 deletions demo/protocol-demo/src/demonstrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ impl Party {
/// Verify a certificate
pub fn verify_message(&self, message: &Bytes) -> Result<(), String> {
match self.get_aggregate(message) {
Some(msig) => match self.clerk.as_ref().unwrap().verify_msig(msig, message) {
Some(msig) => match msig.verify(
message,
&self.clerk.as_ref().unwrap().compute_avk(),
&self.params.unwrap(),
) {
Ok(_) => {
println!(
"Party #{}: aggregate signature successfully verified for {}!",
Expand Down Expand Up @@ -253,7 +257,11 @@ impl Verifier {
message: &Bytes,
msig: &ProtocolMultiSignature,
) -> Result<(), String> {
match self.clerk.as_ref().unwrap().verify_msig(msig, message) {
match msig.verify(
message,
&self.clerk.as_ref().unwrap().compute_avk(),
&self.params.unwrap(),
) {
Ok(_) => {
println!(
"Verifier: aggregate signature successfully verified for {}!",
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/http_server.rs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion mithril-aggregator/src/multi_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ impl MultiSigner for MultiSignerImpl {
.get_current_message()
.ok_or_else(ProtocolError::UnavailableMessage)?;
let clerk = self.clerk();
match clerk.verify_sig(signature, message) {
let avk = clerk.compute_avk();
match signature.verify(&self.protocol_parameters.unwrap(), &avk, message) {
Ok(_) => {
// Register single signature
self.single_signatures
Expand Down
15 changes: 9 additions & 6 deletions mithril-client/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl VerifierImpl {
&self,
signers_with_stakes: &[entities::SignerWithStake],
protocol_parameters: &entities::ProtocolParameters,
) -> Result<ProtocolClerk, String> {
) -> Result<ProtocolClerk, ProtocolError> {
let stakes = signers_with_stakes
.iter()
.map(|signer| {
Expand Down Expand Up @@ -87,13 +87,16 @@ impl Verifier for VerifierImpl {
protocol_parameters: &entities::ProtocolParameters,
) -> Result<(), ProtocolError> {
debug!("Verify multi signature for {:?}", message);
let clerk = self.create_clerk(signers_with_stakes, protocol_parameters);
let multi_signature: ProtocolMultiSignature =
key_decode_hex(multi_signature).map_err(ProtocolError::VerifyMultiSignatureError)?;
clerk
.as_ref()
.unwrap()
.verify_msig(&multi_signature, message)
multi_signature
.verify(
message,
&self
.create_clerk(signers_with_stakes, protocol_parameters)?
.compute_avk(),
&protocol_parameters.to_owned().into(),
)
.map_err(|e| ProtocolError::VerifyMultiSignatureError(e.to_string()))
}
}
Expand Down
8 changes: 4 additions & 4 deletions mithril-common/src/crypto_helper/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use mithril::key_reg::KeyReg;
use mithril::stm::{
Index, PartyId, Stake, StmClerk, StmInitializer, StmMultiSig, StmParameters, StmSig, StmSigner,
StmVerificationKey,
Index, PartyId, Stake, StmAggrSig, StmClerk, StmInitializer, StmParameters, StmSig, StmSigner,
StmVerificationKeyPoP,
};

use super::super::entities;
Expand All @@ -20,8 +20,8 @@ pub type ProtocolInitializer = StmInitializer;
pub type ProtocolClerk = StmClerk<D>;
pub type ProtocolKeyRegistration = KeyReg;
pub type ProtocolSingleSignature = StmSig<D>;
pub type ProtocolMultiSignature = StmMultiSig<D>;
pub type ProtocolSignerVerificationKey = StmVerificationKey;
pub type ProtocolMultiSignature = StmAggrSig<D>;
pub type ProtocolSignerVerificationKey = StmVerificationKeyPoP;

impl From<ProtocolParameters> for entities::ProtocolParameters {
fn from(other: ProtocolParameters) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion mithril-core/benches/stm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ where
let clerk = StmClerk::from_signer(&party_dummy);
let msig = clerk.aggregate(&sigs, &msg).unwrap();
group.bench_function("Verification", |b| {
b.iter(|| clerk.verify_msig(&msig, &msg).is_ok())
b.iter(|| msig.verify(&msg, &clerk.compute_avk(), &params).is_ok())
});
}

Expand Down
17 changes: 0 additions & 17 deletions mithril-core/build.rs

This file was deleted.

47 changes: 0 additions & 47 deletions mithril-core/c-tests/README.md

This file was deleted.

Loading