Compare commits
1
Commits
xcode14
...
sign-pinless
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3870c6669 |
@@ -40,5 +40,5 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'com.facebook.react:react-native:+'
|
||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.60'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.1.0'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.2.1'
|
||||
}
|
||||
|
||||
@@ -220,6 +220,20 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void signPinless(final String hash, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.signPinless(hash));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void installApplet(final Promise promise) {
|
||||
final ReactContext ctx = this.reactContext;
|
||||
|
||||
@@ -507,4 +507,28 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
return sig;
|
||||
}
|
||||
|
||||
public String signPinless(final String message) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
byte[] hash = Hex.decode(message);
|
||||
RecoverableSignature signature = new RecoverableSignature(hash, cmdSet.signPinless(hash).checkOK().getData());
|
||||
|
||||
Log.i(TAG, "Signed hash: " + Hex.toHexString(hash));
|
||||
Log.i(TAG, "Recovery ID: " + signature.getRecId());
|
||||
Log.i(TAG, "R: " + Hex.toHexString(signature.getR()));
|
||||
Log.i(TAG, "S: " + Hex.toHexString(signature.getS()));
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
out.write(signature.getR());
|
||||
out.write(signature.getS());
|
||||
out.write(signature.getRecId());
|
||||
|
||||
String sig = Hex.toHexString(out.toByteArray());
|
||||
Log.i(TAG, "Signature: " + sig);
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user