-
Notifications
You must be signed in to change notification settings - Fork 59
No id creation #25
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
berendsliedrecht
merged 17 commits into
hyperledger:main
from
berendsliedrecht:no-id-creation
Dec 15, 2022
Merged
No id creation #25
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fd58fed
do not validate and create ids for schema, cred defs and rev reg defs
c9de6d2
tests pass
berendsliedrecht 38e9a55
brought back ffi method to get schema from cred def
berendsliedrecht 210a2df
added a wrapper around the SchemaId type
d3e6205
ran formatter
39667a0
added thin wrapper around anoncred ids
71faf19
ran formatter
ac55a6c
add validation to the identifier
b91b83e
use CredentialDefinitionId internally more
e4d5b22
use CredentialDefinitionId internal
7c31824
removed todo for schema index matching
a02dee0
added more validation
c6ade21
validate schema and credential definition
aa6cc35
ran formatter
d191d98
validate by default
b321bd4
wrapper around rev_reg_id
57ed97a
formatted code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,15 @@ use std::collections::HashMap; | |
|
||
use zeroize::Zeroize; | ||
|
||
use crate::data_types::identifiers::cred_def::CredentialDefinitionId; | ||
use crate::data_types::identifiers::rev_reg::RevocationRegistryId; | ||
use crate::data_types::identifiers::schema::SchemaId; | ||
use crate::data_types::{Validatable, ValidationError}; | ||
|
||
use super::{cred_def::CredentialDefinitionId, schema::SchemaId}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct Credential { | ||
pub schema_id: SchemaId, | ||
pub cred_def_id: CredentialDefinitionId, | ||
pub rev_reg_id: Option<RevocationRegistryId>, | ||
pub rev_reg_id: Option<String>, | ||
pub values: CredentialValues, | ||
pub signature: ursa::cl::CredentialSignature, | ||
pub signature_correctness_proof: ursa::cl::SignatureCorrectnessProof, | ||
|
@@ -49,8 +48,6 @@ impl Credential { | |
|
||
impl Validatable for Credential { | ||
fn validate(&self) -> Result<(), ValidationError> { | ||
self.schema_id.validate()?; | ||
self.cred_def_id.validate()?; | ||
self.values.validate()?; | ||
|
||
if self.rev_reg_id.is_some() && (self.witness.is_none() || self.rev_reg.is_none()) { | ||
|
@@ -70,8 +67,8 @@ pub struct CredentialInfo { | |
pub referent: String, | ||
pub attrs: ShortCredentialValues, | ||
pub schema_id: SchemaId, | ||
pub cred_def_id: CredentialDefinitionId, | ||
pub rev_reg_id: Option<RevocationRegistryId>, | ||
pub cred_def_id: String, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason why we do not use CredentialDefinitionId here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I think that one was not changed, I will update this. |
||
pub rev_reg_id: Option<String>, | ||
pub cred_rev_id: Option<String>, | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#[macro_export] | ||
macro_rules! impl_anoncreds_object_identifier { | ||
($i:ident) => { | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, Default)] | ||
pub struct $i(pub String); | ||
|
||
impl $i { | ||
pub fn new(s: impl Into<String>) -> Self { | ||
Self(s.into()) | ||
} | ||
|
||
pub fn validated_new( | ||
s: impl Into<String>, | ||
) -> Result<Self, crate::data_types::ValidationError> { | ||
let s = Self(s.into()); | ||
s.validate()?; | ||
Ok(s) | ||
} | ||
} | ||
|
||
impl crate::data_types::Validatable for $i { | ||
dkulic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn validate(&self) -> Result<(), crate::data_types::ValidationError> { | ||
// TODO: better URI regex | ||
let uri_regex = regex::Regex::new(r".*").unwrap(); | ||
uri_regex | ||
.captures(&self.0) | ||
.ok_or_else(|| { | ||
indy_utils::invalid!( | ||
"type: {}, identifier: {} is invalid. It MUST be a URI.", | ||
stringify!($i), | ||
self.0 | ||
) | ||
}) | ||
.map(|_| ()) | ||
} | ||
} | ||
|
||
impl Into<String> for $i { | ||
fn into(self) -> String { | ||
self.0 | ||
} | ||
} | ||
|
||
impl From<String> for $i { | ||
fn from(value: String) -> Self { | ||
$i::new(value) | ||
} | ||
} | ||
|
||
impl From<&str> for $i { | ||
fn from(value: &str) -> Self { | ||
$i::new(value.to_owned()) | ||
} | ||
} | ||
|
||
impl std::fmt::Display for $i { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.0) | ||
} | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ pub mod rev_reg_def; | |
|
||
/// V1 credential schemas | ||
pub mod schema; | ||
|
||
/// Macros for the data types | ||
pub mod macros; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.