aboutsummaryrefslogtreecommitdiffstats
path: root/sample/bls12_381_smpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sample/bls12_381_smpl.cpp')
-rw-r--r--sample/bls12_381_smpl.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/sample/bls12_381_smpl.cpp b/sample/bls12_381_smpl.cpp
new file mode 100644
index 0000000..c324ffa
--- /dev/null
+++ b/sample/bls12_381_smpl.cpp
@@ -0,0 +1,21 @@
+#include <bls/bls384_256.h>
+#include <string.h>
+#include <stdio.h>
+
+int main()
+{
+ blsSecretKey sec;
+ blsPublicKey pub;
+ blsSignature sig;
+ const char *msg = "abc";
+ const size_t msgSize = strlen(msg);
+ int ret = blsInit(MCL_BLS12_381, MCLBN_COMPILED_TIME_VAR);
+ if (ret) {
+ printf("err %d\n", ret);
+ return 1;
+ }
+ blsSecretKeySetByCSPRNG(&sec);
+ blsGetPublicKey(&pub, &sec);
+ blsSign(&sig, &sec, msg, msgSize);
+ printf("verify %d\n", blsVerify(&sig, &pub, msg, msgSize));
+}