Skip to content

Commit

Permalink
Merge branch '0.3.2' into 0.3.2-android
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungBaeJeon committed Jul 6, 2021
2 parents deb71f7 + 1de70a4 commit 4c51c2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.metadium</groupId>
<artifactId>did-sdk-java</artifactId>
<version>0.3.1</version>
<version>0.3.2</version>

<name>Metadium DID SDK </name>
<description>Java library for Metadium DID</description>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/metadium/did/MetadiumWallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import java.math.BigInteger;
import java.net.URI;
import java.security.InvalidAlgorithmParameterException;
import java.security.SecureRandom;
import java.text.ParseException;
import java.util.Base64;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -394,7 +396,10 @@ public SignedJWT sign(Verifiable verifiable, JWTClaimsSet claimsSet) throws JOSE
else if (verifiable instanceof VerifiablePresentation) {
((VerifiablePresentation)verifiable).setHolder(URI.create(getDid()));
}
return verifiable.sign(getKid(), getDid(), new ECDSASigner(key.getECPrivateKey()), claimsSet);
// nonce 생성
byte[] nonce = new byte[32];
new SecureRandom().nextBytes(nonce);
return verifiable.sign(getKid(), Base64.getEncoder().encodeToString(nonce), new ECDSASigner(key.getECPrivateKey()), claimsSet);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/metadium/did/VerifiableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void testVerifing() throws DidException, JOSEException, IOException, Pars
userWallet.getDid(),
Collections.singletonMap("name", "mansud")
).serialize();
System.out.println("vc : "+signedNameVC);

// User verify nameVC
SignedJWT nameJWT = SignedJWT.parse(signedNameVC);
Expand All @@ -78,6 +79,7 @@ public void testVerifing() throws DidException, JOSEException, IOException, Pars
userWallet.getDid(),
Collections.singletonMap("birth", "19770206")
).serialize();
System.out.println("vc : "+signedBirthVC);

// User verify nameVC
SignedJWT birthJWT = SignedJWT.parse(signedBirthVC);
Expand All @@ -95,6 +97,7 @@ public void testVerifing() throws DidException, JOSEException, IOException, Pars
expire.getTime(),
Arrays.asList(signedNameVC, signedBirthVC)
).serialize();
System.out.println("vp : "+signedVp);

// Verifier verify VP
SignedJWT vpJWT = SignedJWT.parse(signedVp);
Expand Down

0 comments on commit 4c51c2d

Please sign in to comment.