Skip to content
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

[crypto] Unify Narwhal and Sui Crypto #2994

Merged
merged 23 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove clippy
  • Loading branch information
punwai committed Jul 21, 2022
commit 9bae178447f7411d600eab36370bcfd4fd45fa8d
390 changes: 207 additions & 183 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use move_binary_format::CompiledModule;
use move_core_types::ident_str;
use move_core_types::language_storage::ModuleId;
use move_vm_runtime::native_functions::NativeFunctionTable;
use narwhal_crypto::traits::VerifyingKey;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::{BTreeMap, HashSet};
use std::{fs, path::Path};
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-core/src/generate_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use signature::Signer;
use std::{fs::File, io::Write};
use sui_types::{
base_types::{self, ObjectDigest, ObjectID, TransactionDigest, TransactionEffectsDigest},
batch::UpdateItem,
// batch::UpdateItem,
crypto::{get_key_pair, AuthoritySignature, KeypairTraits, PublicKeyBytes, Signature},
messages::{
CallArg, EntryArgumentErrorKind, ExecutionFailureStatus, ExecutionStatus, ObjectArg,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-sdk/examples/transfer_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn main() -> Result<(), anyhow::Error> {
.execute_transaction(
transfer_tx.tx_bytes,
Base64::from_bytes(signature.signature_bytes()),
Base64::from_bytes(signature.public_key_bytes().as_ref()),
Base64::from_bytes(signature.public_key_bytes()),
)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/sui-sdk/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};

use sui_types::base_types::{SuiAddress, ToAddress};
use sui_types::crypto::{get_key_pair, KeyPair, KeypairTraits, PublicKeyBytes, Signature};
use sui_types::crypto::{get_key_pair, KeyPair, KeypairTraits, Signature};

#[derive(Serialize, Deserialize)]
#[non_exhaustive]
Expand Down
3 changes: 1 addition & 2 deletions crates/sui-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ impl Signature {
pub fn get_verification_inputs(
&self,
author: SuiAddress,
) -> Result<(AccountSignature, PublicKeyBytes), SuiError>
{
) -> Result<(AccountSignature, PublicKeyBytes), SuiError> {
// Is this signature emitted by the expected author?
let public_key_bytes: PublicKeyBytes =
PublicKeyBytes::from_bytes(self.public_key_bytes()).expect("byte lengths match");
Expand Down
10 changes: 2 additions & 8 deletions crates/sui-types/src/unit_tests/messages_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,15 @@ fn test_certificates() {
.unwrap()
.is_none());
let c = builder
.append(
v2.auth_sign_info.authority,
v2.auth_sign_info.signature
)
.append(v2.auth_sign_info.authority, v2.auth_sign_info.signature)
.unwrap()
.unwrap();

assert!(c.verify(&committee).is_ok());

let mut builder = SignatureAggregator::try_new(transaction, &committee).unwrap();
assert!(builder
.append(
v1.auth_sign_info.authority,
v1.auth_sign_info.signature
)
.append(v1.auth_sign_info.authority, v1.auth_sign_info.signature)
.unwrap()
.is_none());
assert!(builder
Expand Down
5 changes: 1 addition & 4 deletions crates/sui/src/genesis_ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ use sui_config::{
use sui_types::{
base_types::{encode_bytes_hex, ObjectID, SuiAddress},
crypto::KeyPair,
crypto::{
get_key_pair, AuthoritySignature, KeypairTraits, PublicKey, PublicKeyBytes, Signature,
ToFromBytes,
},
crypto::{KeypairTraits, PublicKeyBytes, Signature, ToFromBytes},
object::Object,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/keytool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl KeyToolCommand {
println!(
" {0: ^42} | {1: ^45} ",
keypair.public().to_address(),
Base64::encode(keypair.public().as_ref().to_vec()),
Base64::encode(keypair.public().as_ref()),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/sui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sui_config::{
use sui_sdk::crypto::{KeystoreType, SuiKeystore};
use sui_sdk::SuiClient;
use sui_swarm::memory::Swarm;
use sui_types::base_types::{SuiAddress, ToAddress};
use sui_types::base_types::ToAddress;
use sui_types::crypto::KeypairTraits;
use tracing::info;

Expand Down