Skip to content

Commit

Permalink
added challenge to authenticate method, needed if we want to add to t…
Browse files Browse the repository at this point in the history
…he proof the challenge when we are trying to authenticate with on-chain circuits
  • Loading branch information
emuroni committed Oct 13, 2023
1 parent a552fc6 commit a48fc6c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
18 changes: 11 additions & 7 deletions lib/iden3comm/domain/use_cases/authenticate_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ class AuthenticateParam {
final String privateKey;
final String? pushToken;
final Map<int, Map<String, dynamic>>? nonRevocationProofs;
final String? challenge;

AuthenticateParam(
{required this.message,
required this.genesisDid,
required this.profileNonce,
required this.privateKey,
this.pushToken,
this.nonRevocationProofs});
AuthenticateParam({
required this.message,
required this.genesisDid,
required this.profileNonce,
required this.privateKey,
this.pushToken,
this.nonRevocationProofs,
this.challenge,
});
}

class AuthenticateUseCase extends FutureUseCase<AuthenticateParam, void> {
Expand Down Expand Up @@ -104,6 +107,7 @@ class AuthenticateUseCase extends FutureUseCase<AuthenticateParam, void> {
stateContractAddr: env.idStateContract,
ipfsNodeUrl: env.ipfsUrl,
nonRevocationProofs: param.nonRevocationProofs,
challenge: param.challenge,
));
_stacktraceManager
.addTrace("[AuthenticateUseCase] _getIden3commProofsUseCase success");
Expand Down
20 changes: 12 additions & 8 deletions lib/sdk/iden3comm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ abstract class PolygonIdSdkIden3comm {
BigInt? profileNonce,
required String privateKey,
String? pushToken,
String? challenge,
});

/// Gets a list of [InteractionEntity] associated to the identity previously stored
Expand Down Expand Up @@ -401,6 +402,7 @@ class Iden3comm implements PolygonIdSdkIden3comm {
required String privateKey,
String? pushToken,
Map<int, Map<String, dynamic>>? nonRevocationProofs,
String? challenge,
}) {
_stacktraceManager.clear();
if (message is! AuthIden3MessageEntity) {
Expand All @@ -411,14 +413,16 @@ class Iden3comm implements PolygonIdSdkIden3comm {
}

return _authenticateUseCase.execute(
param: AuthenticateParam(
message: message,
genesisDid: genesisDid,
profileNonce: profileNonce ?? GENESIS_PROFILE_NONCE,
privateKey: privateKey,
pushToken: pushToken,
nonRevocationProofs: nonRevocationProofs,
));
param: AuthenticateParam(
message: message,
genesisDid: genesisDid,
profileNonce: profileNonce ?? GENESIS_PROFILE_NONCE,
privateKey: privateKey,
pushToken: pushToken,
nonRevocationProofs: nonRevocationProofs,
challenge: challenge,
),
);
}

@override
Expand Down
15 changes: 9 additions & 6 deletions lib/sdk/polygonid_flutter_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,17 @@ class PolygonIdFlutterChannel
required String privateKey,
String? pushToken,
Map<int, Map<String, dynamic>>? nonRevocationProofs,
String? challenge,
}) {
return _polygonIdSdk.iden3comm.authenticate(
message: message,
genesisDid: genesisDid,
profileNonce: profileNonce,
privateKey: privateKey,
pushToken: pushToken,
nonRevocationProofs: nonRevocationProofs);
message: message,
genesisDid: genesisDid,
profileNonce: profileNonce,
privateKey: privateKey,
pushToken: pushToken,
nonRevocationProofs: nonRevocationProofs,
challenge: challenge,
);
}

@override
Expand Down

0 comments on commit a48fc6c

Please sign in to comment.