-
Notifications
You must be signed in to change notification settings - Fork 83
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
anoncreds-rs integration #1110
anoncreds-rs integration #1110
Conversation
3a79dbc
to
570f8e8
Compare
e424f28
to
b7f2a91
Compare
5af7353
to
5a3c359
Compare
@@ -192,8 +192,14 @@ pub async fn dev_build_featured_anoncreds() -> impl BaseAnonCreds { | |||
return IndyCredxAnonCreds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I compile with both credx
and anoncreds
flags enabled, by mistake, the build will go through and this function and return credx
implementation (while I perhaps only intended to run with anoncreds
).
Something like
#[cfg(all(feature = "credx", feature = "anoncreds"))]
compile_error!("You can not enable 'credx' and 'anoncreds' features simultaneously. Choose one.");
Then the cfg conditions bellow can maybe also can be simplified by dropping the not
part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using --all-features
flag in CI, and I am using it myself in my current LSP config. Although this should be avoided if at all possible, I can still change both (and switch feature flags manually), but I think for now, following a priority order of credx
, anoncreds-rs
, mock
in case of "conflicting" feature flags as suggested by the Cargo Book is fine.
5a3c359
to
53d3ebc
Compare
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job 👍 left some comments, nothing big though
Haven't yet covered everything in the anoncreds.rs
file
} | ||
|
||
impl Anoncreds { | ||
async fn get_wallet_record_value<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Wouldn't mind to make this part of wallet API, not in this PR though.
None | ||
}; | ||
|
||
// WTF, anoncreds-rs expects the whole status list just to use the accumulator :| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the sometimes emotional nature of the job, but lets keep the comments assertive in the source code ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about you create tracking issue in anoncreds-rs repo to improve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, it may be fine to keep the API as thin as possible type-wise. It needs to be carefully considered what changes to anoncreds-rs are necessary. Not my priority right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, can we track it? If the API was annoying enough to leave that comment, it's probably worthy of tracking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, at this point, I only know some changes will be necessary (which is obviated by the fact we are using custom fork - hence no need to track IMO), but I don't know which ones. This question will get deserved attention later.
.add_wallet_record( | ||
CATEGORY_CRED_MAP_SCHEMA_ID, | ||
&cred_def_id.0, | ||
&json!({"schemaId": schema_id}).to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the record category states explicitly enough what the value is. Not strongly against it, not fan either.
But also: I observe that you are willing to give up backwards compatibility (knowingly or unknowingly). If that would be the case, I wonder if there's other breaking changes we can/want to do?
Also I wonder what backwards non-compatibility implies for migration from credx -> anoncreds. Bit late now so I'll save that thinking for later ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about explicitness, it needs to be a json (again, this code should not exist)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honest question - how come? Doesn't seem to be json in credx implementation
wallet
.add_wallet_record(
CATEGORY_CRED_MAP_SCHEMA_ID,
&cred_def_id.0,
&schema.id().0,
None,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, you may be right, I will look into it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep somewhere comment that we currently only support ISSUANCE_ON_DEMAND
IssuanceType, and it's the default
let rev_reg = cred.rev_reg.as_ref(); | ||
|
||
let cred_rev_id = | ||
if let (Some(rev_reg_id), Some(rev_reg), Some((_, _, _, _, rev_reg_info, _))) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I know this is mostly copy-paste, but I'll take opportunity to comment this. We should only be testing one (preferably the input rev_reg_id
, as that the initial source of truth as whether we issue revocable or irrevocable credential), not all tree for Some
, and throw an error else.
If first of the tuple is Some
, but other are None
, something must had gone unexpectedly wrong, likely due a bug - so we shouldn't instead silently treat that same way as we treat irrevocable credentials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Approved from my side, I trust my comments are acknowledged whether they would be addressed here or in the next rounds.
Feel free to merge if you are ready.
None | ||
}; | ||
|
||
// WTF, anoncreds-rs expects the whole status list just to use the accumulator :| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, can we track it? If the API was annoying enough to leave that comment, it's probably worthy of tracking
// Otherwise, create cred def | ||
let (cred_def, cred_def_priv, cred_key_correctness_proof) = | ||
anoncreds::issuer::create_credential_definition( | ||
// Schema ID must be just the schema seq no for some reason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, please let's track this somewhere. Can be just single comprehensive issue with a brief list of issues we run into with anoncreds-rs and needs to be looked into.
.add_wallet_record( | ||
CATEGORY_CRED_MAP_SCHEMA_ID, | ||
&cred_def_id.0, | ||
&json!({"schemaId": schema_id}).to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honest question - how come? Doesn't seem to be json in credx implementation
wallet
.add_wallet_record(
CATEGORY_CRED_MAP_SCHEMA_ID,
&cred_def_id.0,
&schema.id().0,
None,
)
None, | ||
Some(prover_did.did()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: it would be preferable to swap these. Provide first argument entropy
of value Some(prover_did)
, and provide None
for the 2nd arg.
I don't know why this became 2 arguments in anoncreds-rs, originally it was prover_did
later renamed to entropy
to reflect actual purpose of the parameter. But there was a shift from dealing with "prover_did" to more generally "some entropy".
}); | ||
let registry = CryptoRevocationRegistry { accum }; | ||
|
||
// let rev_status_list = create_revocation_status_list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
A first working implementation of
BaseAnoncreds
trait usinganoncreds-rs
. Not final. Will be improved significantly in the forthcoming PRs.