-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.java
More file actions
26 lines (20 loc) · 1.06 KB
/
Copy pathbackend.java
File metadata and controls
26 lines (20 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public RpcResponse<String> authorizeFacultyNftMint(CustomMintRequest customMintRequest) {
log.info("Signing message: " + customMintRequest.toString());
byte[] toSign;
try {
toSign = Utils.getConfiguredObjectMapper().writeValueAsString(customMintRequest).getBytes();
} catch (Exception e) {
return RpcResponse.withError("Failed to serialize message: " + e.getMessage());
}
try {
Credentials credentials = facultyCredentials.getCredentials();
Sign.SignatureData signatureData = Sign.signMessage(toSign, credentials.getEcKeyPair(), true);
byte[] value = new byte[65];
System.arraycopy(signatureData.getR(), 0, value, 0, 32);
System.arraycopy(signatureData.getS(), 0, value, 32, 32);
System.arraycopy(signatureData.getV(), 0, value, 64, 1);
return RpcResponse.of(Numeric.toHexString(value));
} catch (Exception e) {
return RpcResponse.withError("Failed to sign message: " + e.getMessage());
}
}