Skip to content

Commit

Permalink
Merge pull request #104 from Concordium/web3id-revision
Browse files Browse the repository at this point in the history
Web3id revision
  • Loading branch information
abizjak authored Aug 1, 2023
2 parents 9445eca + 9df8903 commit f4fa470
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 227 deletions.
2 changes: 1 addition & 1 deletion concordium-base
Submodule concordium-base updated 95 files
+5 −1 .diff-wat-wasm.sh
+0 −42 CHANGELOG.md
+0 −2 README.md
+1 −1 concordium-contracts-common
+0 −7 haskell-bins/genesis/README.md
+21 −0 haskell-src/Concordium/Cost.hs
+11 −0 haskell-src/Concordium/Genesis/Data.hs
+67 −1 haskell-src/Concordium/Genesis/Data/P6.hs
+5 −0 haskell-src/Concordium/ID/Types.hs
+1 −0 haskell-src/Concordium/Types/InvokeContract.hs
+34 −0 haskell-src/Concordium/Types/Migration.hs
+43 −0 haskell-src/Concordium/Types/ProtocolVersion.hs
+17 −4 haskell-src/Concordium/Types/SeedState.hs
+21 −9 haskell-src/Concordium/Types/Transactions.hs
+3 −2 identity-provider-service/Cargo.lock
+3 −2 idiss/Cargo.lock
+3 −2 mobile_wallet/Cargo.lock
+8 −8 mobile_wallet/src/lib.rs
+3 −2 rust-bins/Cargo.lock
+0 −115 rust-bins/data-generation-notes.md
+3 −3 rust-bins/src/bin/client.rs
+5 −5 rust-bins/src/bin/generate_testdata.rs
+0 −438 rust-bins/src/bin/genesis_tool.rs
+3 −3 rust-bins/src/bin/user_cli.rs
+303 −265 rust-src/Cargo.lock
+11 −0 rust-src/concordium_base/CHANGELOG.md
+2 −2 rust-src/concordium_base/benches/compute_message.rs
+2 −2 rust-src/concordium_base/benches/verify_cdi.rs
+2 −38 rust-src/concordium_base/src/base.rs
+14 −17 rust-src/concordium_base/src/cis4_types.rs
+16 −1 rust-src/concordium_base/src/common/impls.rs
+18 −5 rust-src/concordium_base/src/common/types.rs
+2 −7 rust-src/concordium_base/src/constants.rs
+2 −2 rust-src/concordium_base/src/id/account_holder.rs
+6 −6 rust-src/concordium_base/src/id/chain.rs
+2 −2 rust-src/concordium_base/src/id/ffi.rs
+1 −1 rust-src/concordium_base/src/id/id_verifier.rs
+3 −3 rust-src/concordium_base/src/id/identity_provider.rs
+3 −3 rust-src/concordium_base/src/id/test.rs
+100 −68 rust-src/concordium_base/src/id/types.rs
+3 −2 rust-src/concordium_base/src/id/utils.rs
+77 −8 rust-src/concordium_base/src/transactions.rs
+285 −221 rust-src/concordium_base/src/web3id/mod.rs
+1 −1 rust-src/concordium_base_derive/Cargo.toml
+9 −5 rust-src/concordium_base_derive/src/lib.rs
+52 −46 rust-src/key_derivation/src/lib.rs
+ smart-contracts/testdata/contracts/global-data-section-test.wasm
+23 −0 smart-contracts/testdata/contracts/global-data-section-test.wat
+ smart-contracts/testdata/contracts/global-element-section-test.wasm
+24 −0 smart-contracts/testdata/contracts/global-element-section-test.wat
+ smart-contracts/testdata/contracts/v1/account-signature-checks.wasm
+52 −0 smart-contracts/testdata/contracts/v1/account-signature-checks.wat
+ smart-contracts/testdata/contracts/v1/checkpointing-2.wasm
+265 −0 smart-contracts/testdata/contracts/v1/checkpointing-2.wat
+ smart-contracts/testdata/contracts/v1/i32.extend16_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i32.extend16_s.wat
+ smart-contracts/testdata/contracts/v1/i32.extend8_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i32.extend8_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend16_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend16_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend32_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend32_s.wat
+ smart-contracts/testdata/contracts/v1/i64.extend8_s.wasm
+8 −0 smart-contracts/testdata/contracts/v1/i64.extend8_s.wat
+ smart-contracts/testdata/contracts/v1/upgrading_1_with_custom_section.wasm
+12 −0 smart-contracts/wasm-chain-integration/CHANGELOG.md
+510 −342 smart-contracts/wasm-chain-integration/Cargo.lock
+2 −2 smart-contracts/wasm-chain-integration/Cargo.toml
+ smart-contracts/wasm-chain-integration/benches/code/loop-energy.wasm
+34 −0 smart-contracts/wasm-chain-integration/benches/code/loop-energy.wat
+5 −1 smart-contracts/wasm-chain-integration/benches/v1-host-functions.rs
+74 −20 smart-contracts/wasm-chain-integration/benches/wasm.rs
+3 −2 smart-contracts/wasm-chain-integration/src/constants.rs
+17 −6 smart-contracts/wasm-chain-integration/src/utils.rs
+11 −2 smart-contracts/wasm-chain-integration/src/v0/ffi.rs
+17 −4 smart-contracts/wasm-chain-integration/src/v0/mod.rs
+3 −1 smart-contracts/wasm-chain-integration/src/v1/crypto_primitives_tests.rs
+34 −7 smart-contracts/wasm-chain-integration/src/v1/ffi.rs
+125 −14 smart-contracts/wasm-chain-integration/src/v1/mod.rs
+64 −11 smart-contracts/wasm-chain-integration/src/validation_tests.rs
+40 −28 smart-contracts/wasm-test/Cargo.lock
+7 −3 smart-contracts/wasm-test/src/main.rs
+9 −0 smart-contracts/wasm-transform/CHANGELOG.md
+1 −1 smart-contracts/wasm-transform/Cargo.toml
+22 −0 smart-contracts/wasm-transform/src/artifact.rs
+2 −0 smart-contracts/wasm-transform/src/lib.rs
+5 −0 smart-contracts/wasm-transform/src/machine.rs
+5 −0 smart-contracts/wasm-transform/src/metering_transformation.rs
+94 −24 smart-contracts/wasm-transform/src/parse.rs
+65 −0 smart-contracts/wasm-transform/src/tests.rs
+8 −0 smart-contracts/wasm-transform/src/types.rs
+31 −6 smart-contracts/wasm-transform/src/utils.rs
+58 −7 smart-contracts/wasm-transform/src/validate.rs
+ smart-contracts/wasm-transform/testdata/sign-ext-instructions.wasm
+62 −0 smart-contracts/wasm-transform/testdata/sign-ext-instructions.wat
2 changes: 1 addition & 1 deletion examples/create-initial-accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn main() -> anyhow::Result<()> {
)]
.into_iter()
.collect(),
threshold: SignatureThreshold(1),
threshold: SignatureThreshold::ONE,
};
let prf_key = SecretKey::<ArCurve>::generate_non_zero(&mut csprng);
let cred_id_exponent = prf_key.prf_exponent(0).expect("We were very unlucky.");
Expand Down
2 changes: 1 addition & 1 deletion examples/v2_create_initial_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn main() -> anyhow::Result<()> {
)]
.into_iter()
.collect(),
threshold: SignatureThreshold(1),
threshold: SignatureThreshold::ONE,
};
let prf_key = SecretKey::<ArCurve>::generate_non_zero(&mut csprng);
let cred_id_exponent = prf_key.prf_exponent(0).expect("We were very unlucky.");
Expand Down
44 changes: 29 additions & 15 deletions src/cis4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
pub use concordium_base::{cis2_types::MetadataUrl, cis4_types::*};
use concordium_base::{
constants::MAX_PARAMETER_LEN,
contracts_common::{self, AccountAddress},
contracts_common,
hashes::TransactionHash,
smart_contracts::{ExceedsParameterSize, OwnedParameter},
web3id::{CredentialHolderId, Web3IdSigner, REVOKE_DOMAIN_STRING},
Expand Down Expand Up @@ -43,6 +43,19 @@ impl From<RejectReason> for Cis4QueryError {
fn from(value: RejectReason) -> Self { Self::NodeRejected(value) }
}

impl Cis4QueryError {
/// Check if the error variant is a logic error, i.e., the query
/// was received by the node which attempted to execute it, and it failed.
/// If so, extract the reason for execution failure.
pub fn is_contract_error(&self) -> Option<&crate::types::RejectReason> {
if let Self::NodeRejected(e) = self {
Some(e)
} else {
None
}
}
}

#[derive(thiserror::Error, Debug)]
/// An error that can occur when sending CIS4 update transactions.
pub enum Cis4TransactionError {
Expand Down Expand Up @@ -115,20 +128,20 @@ impl Cis4Contract {
self.view_raw("revocationKeys", parameter, bi).await
}

/// Look up the issuer's metadata URL.
pub async fn issuer_metadata(
/// Look up the credential registry's metadata.
pub async fn registry_metadata(
&mut self,
bi: impl IntoBlockIdentifier,
) -> Result<MetadataUrl, Cis4QueryError> {
) -> Result<RegistryMetadata, Cis4QueryError> {
let parameter = OwnedParameter::empty();
self.view_raw("issuerMetadata", parameter, bi).await
self.view_raw("registryMetadata", parameter, bi).await
}

/// Look up the issuer's account address.
pub async fn issuer_address(
/// Look up the issuer's public key.
pub async fn issuer(
&mut self,
bi: impl IntoBlockIdentifier,
) -> Result<AccountAddress, Cis4QueryError> {
) -> Result<IssuerKey, Cis4QueryError> {
let parameter = OwnedParameter::empty();

self.view_raw("issuer", parameter, bi).await
Expand Down Expand Up @@ -174,9 +187,9 @@ impl Cis4Contract {
.await
}

/// Revoke a credential as an issuer.
/// Revoke a credential as the holder.
///
/// The extra nonce that must be provided is the owner's nonce inside the
/// The extra nonce that must be provided is the holder's nonce inside the
/// contract. The signature on this revocation message is set to expire at
/// the same time as the transaction.
pub async fn revoke_credential_as_holder(
Expand Down Expand Up @@ -218,12 +231,13 @@ impl Cis4Contract {
.await
}

/// Revoke a credential as a revoker.
/// Revoke a credential as another party, distinct from issuer or holder.
///
/// The extra nonce that must be provided is the owner's nonce inside the
/// contract. The signature on this revocation message is set to expire at
/// The extra nonce that must be provided is the nonce associated with the
/// key that signs the revocation message.
/// The signature on this revocation message is set to expire at
/// the same time as the transaction.
pub async fn revoke_credential_as_revoker(
pub async fn revoke_credential_other(
&mut self,
signer: &impl transactions::ExactSizeTransactionSigner,
metadata: &Cis4TransactionMetadata,
Expand Down Expand Up @@ -261,7 +275,7 @@ impl Cis4Contract {
parameter_vec.extend_from_slice(&to_sign[REVOKE_DOMAIN_STRING.len()..]);
let parameter = OwnedParameter::try_from(parameter_vec)?;

self.update_raw(signer, metadata, "revokeCredentialHolder", parameter)
self.update_raw(signer, metadata, "revokeCredentialOther", parameter)
.await
}
}
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,7 @@ impl WalletAccount {
keys.insert(ci, public);
}
AccountAccessStructure {
threshold: AccountThreshold::try_from(self.keys.threshold.0).unwrap(),
threshold: self.keys.threshold,
keys,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/smart_contracts.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Types related to smart contracts.

use super::{Address, ContractAddress, Energy, RejectReason};
pub use concordium_base::smart_contracts::*;
use concordium_base::{
common::{types::Amount, SerdeDeserialize, SerdeSerialize},
id::types::AccountAddress,
transactions::UpdateContractPayload,
};
pub use concordium_base::{constants::MAX_ALLOWED_INVOKE_ENERGY, smart_contracts::*};
/// Re-export of common helper functionality for smart contract, such as types
/// and serialization specific for smart contracts.
pub use concordium_contracts_common::{
Expand Down
9 changes: 2 additions & 7 deletions src/v2/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,8 @@ impl TryFrom<SignatureThreshold> for crate::id::types::SignatureThreshold {

fn try_from(value: SignatureThreshold) -> Result<Self, Self::Error> {
if let Ok(v) = u8::try_from(value.value) {
if v == 0 {
Err(tonic::Status::internal(
"Unexpected zero signature threshold.",
))
} else {
Ok(Self(v))
}
crate::id::types::SignatureThreshold::try_from(v)
.map_err(|_| tonic::Status::internal("Unexpected zero signature threshold."))
} else {
Err(tonic::Status::internal("Unexpected signature threshold."))
}
Expand Down
Loading

0 comments on commit f4fa470

Please sign in to comment.