public class ZoroAPI extends Object
| 构造器和说明 |
|---|
ZoroAPI() |
| 限定符和类型 | 方法和说明 |
|---|---|
static List<String> |
decrypt(List<String> ciphertextList,
String envelop,
byte[] keyName,
byte[] password)
Returns an list of plaintext string which is decrypted from ciphertextList.
|
static String |
decrypt(String ciphertext,
String envelop,
byte[] keyName,
byte[] password)
Returns an plaintext string which is decrypted from ciphertext.
|
static List<Note> |
decryptAndVerifyCommitment(List<String> commitmentList,
List<String> encryptedValueList,
List<String> encryptedBlindFactorList,
String envelop,
byte[] keyName,
byte[] password)
Decrypts the encrypted blind factor and value of each pedersen commitment and verify the commitment is whether matched or not.
|
static Note |
decryptAndVerifyCommitment(String commitment,
String encryptedValue,
String encryptedBlindFactor,
String envelop,
byte[] keyName,
byte[] password)
Decrypts the encrypted blind factor and value of a pedersen commitment and verify the commitment is whether matched or not.
|
static String |
ecdsaSign(byte[] message,
byte[] keyName,
byte[] password)
Returns the signature of a message.
|
static boolean |
ecdsaverify(ECPublicKey pubkey,
byte[] message,
String signature)
Verify the signature based on public key and message.
|
static String |
generateBlindFactor()
Return a 32-bytes blind factor encoded by Base64
|
static void |
initZoroCryptoSpi(CryptoServiceSpi cryptoServiceSpi) |
static void |
initZoroKeyManagementSpi(KeyManagementSpi keyManagementSpi) |
static String |
mapPlainToPrivacy(Object obj)
Returns an json string which is encrypted from obj.
|
static <T> T |
mapPlainToPrivacy(Object obj,
Class<T> clazz)
Returns an encrypted object which is encrypted from obj.
|
static <T> T |
mapPlainToPrivacyIndirectly(Object obj,
Class<T> clazz)
Returns an encrypted object which is encrypted from obj.
|
static <T> T |
mapPrivacyToPlain(Object obj,
Class<T> clazz,
String selfId,
byte[] keyName,
byte[] password)
Returns an plaintext object which is decrypted from obj.
|
static boolean |
verifyCommitment(String commitment,
String blindFactor,
long value)
Verify commitment is correct with plain blind factor and plain value.
|
static Note |
verifyCommitmentChange(String pc,
String blindFactor,
long value,
byte[] keyName,
byte[] password,
List<? extends EncryptedTuple> positiveTuples,
List<? extends EncryptedTuple> negativeTuples) |
static Note |
verifyCommitmentChange(String pc,
String blindFactor,
long value,
List<? extends PlainTuple> positiveTuples,
List<? extends PlainTuple> negativeTuples)
verify commitment change and accumulate blind factor and value
|
public static void initZoroKeyManagementSpi(KeyManagementSpi keyManagementSpi) throws ZoroException
keyManagementSpi - the Key Management Spi, not nullZoroExceptionpublic static void initZoroCryptoSpi(CryptoServiceSpi cryptoServiceSpi) throws ZoroException
cryptoServiceSpi - the Crypto Service Spi, not nullZoroExceptionpublic static String generateBlindFactor() throws ZoroException
ZoroExceptionpublic static <T> T mapPlainToPrivacy(Object obj, Class<T> clazz) throws ZoroException
ApplyEnvelope,
CommitmentRelation and ProofList.obj - the object to be encryptedclazz - describe an encrypted objectZoroExceptionpublic static String mapPlainToPrivacy(Object obj) throws ZoroException
ApplyEnvelope,
CommitmentRelation and ProofList.obj - the object to be encryptedZoroExceptionpublic static <T> T mapPlainToPrivacyIndirectly(Object obj, Class<T> clazz) throws ZoroException
ApplyEnvelope,
CommitmentRelation and ProofList.
This method is implemented using fastjson, and its function is the same as mapPlainToPrivacy() with the sane parameters.
obj - the object to be encryptedclazz - describe an encrypted objectZoroExceptionpublic static <T> T mapPrivacyToPlain(Object obj, Class<T> clazz, String selfId, byte[] keyName, byte[] password) throws ZoroException
ApplyEnvelope.
Because there is consistent one-to-one match between plaintext and ciphertext, the clazz can be the same as the class of obj.obj - the object to be decryptedclazz - describe an plaintext objectselfId - the id of the caller, also is the member idkeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionpublic static String decrypt(String ciphertext, String envelop, byte[] keyName, byte[] password) throws ZoroException
ciphtetext - the ciphertext need to be decryptedenvelop - the corresponding envelop for ciphertextkeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionpublic static List<String> decrypt(List<String> ciphertextList, String envelop, byte[] keyName, byte[] password) throws ZoroException
ciphertextList - the list of ciphertext need to be decryptedenvelop - the corresponding envelop for ciphertextkeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionpublic static List<Note> decryptAndVerifyCommitment(List<String> commitmentList, List<String> encryptedValueList, List<String> encryptedBlindFactorList, String envelop, byte[] keyName, byte[] password) throws ZoroException
commitmentList - a list of pedersen commitmentencryptedValueList - a list of encrypted blind factorencryptedBlindFactorList - a list of encrypted valueenvelop - the corresponding envelop for encrypted blind factor and valuekeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionNotepublic static Note decryptAndVerifyCommitment(String commitment, String encryptedValue, String encryptedBlindFactor, String envelop, byte[] keyName, byte[] password) throws ZoroException
commitment - a pedersen commitmentencryptedValue - an encrypted blind factorencryptedBlindFactor - an encrypted valueenvelop - the corresponding envelop for encrypted blind factor and valuekeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionNotepublic static boolean verifyCommitment(String commitment, String blindFactor, long value) throws ZoroException
commitment - a pedersen commitmentblindFactor - a blind factorvalue - a valueZoroExceptionpublic static Note verifyCommitmentChange(String pc, String blindFactor, long value, byte[] keyName, byte[] password, List<? extends EncryptedTuple> positiveTuples, List<? extends EncryptedTuple> negativeTuples) throws ZoroException
pc - a pedersen commitment, the final commitmentr - a init plain blind factorv - a init plain valuekeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keypositiveTuples - positive tuplesnegativeTuples - negative tuplesZoroExceptionNote,
EncryptedTuplepublic static Note verifyCommitmentChange(String pc, String blindFactor, long value, List<? extends PlainTuple> positiveTuples, List<? extends PlainTuple> negativeTuples) throws ZoroException
pc - a pedersen commitment, the final commitmentblindFactor - a init plain blind factorvalue - a init plain valuepositiveTuples - positive tuplesnegativeTuples - negative tuplesZoroExceptionNote,
PlainTuplepublic static String ecdsaSign(byte[] message, byte[] keyName, byte[] password) throws ZoroException
message - the message to be signedkeyName - the keyname of the caller, which is used to get the real private keypassword - the password of the caller, which is used to get the real private keyZoroExceptionpublic static boolean ecdsaverify(ECPublicKey pubkey, byte[] message, String signature) throws ZoroException
pubkey - the public keymessage - the message is sighedsignature - the corresponding signature for messageZoroExceptionCopyright © 2022. All rights reserved.