Skip to content

SherLzp/scrypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shercrypto

The project is a crypto library written by myself. This is a long-term task, and the project is still in its infancy. There is still much to be done.

Directory Structure

├─ecc # elliptic curves and its utils
├─encryptions # Encryption algorithms
├─math # wrapped math algorithms
├─signatures # Signature algorithms
├─utils # utils used in our project
└─proof # zero-knowledge algorithms

Curves

  • P256(secp256k1)
  • BN256
  • Curve25519(ed25519)
  • BLS12-381

Algorithms

Encryptions

AES

Proxy Re-Encryption

Signatures

Proof

API

waiting...

Try Once

main.go

package main

import (
	"shercrypto/encryptions/recrypt"
	"shercrypto/encryptions/sherAes"
	"shercrypto/proof/credentials"
	"shercrypto/proof/schnorrNIZK"
	"shercrypto/signatures/algebraicMAC"
	"shercrypto/signatures/ringers17"
)

func main() {
	sherAes.TryOnce()
	schnorrNIZK.TryOnce()
	algebraicMAC.TryOnce()
	recrypt.TryOnce()
	ringers17.TryOnce()
	credentials.TryOnce()
}

result

-----------AES GCM start-------------
PlainText: Hello World
CipherText: e50d7983b9cd370d81acdd6b8ead71ebce7c673360dbe414dda6d2
Text after decryption: Hello World
-----------AES GCM end-------------
-----------Schnorr NIZK start-------------
prove scheme: &{bn256.G1(2765277675911814263603122317192032835792128670690810428723533897562268041823, 49586042462698105485801742848540975459528495301419763370069561998058799158518) 101203739492224907737910371461811686326466639186416900782475394828361486058619 [52535026094174831019939789530503506497719844896198037700538454560875004523747] [bn256.G1(1, -2)] bn256.G1(31579067245623137095840985112895615236000784443397978551196743324484395357803, 8158011723950309062247001133324538857075303033263736761443546011274557459153) bn256.G1(31579067245623137095840985112895615236000784443397978551196743324484395357803, 8158011723950309062247001133324538857075303033263736761443546011274557459153)}
Verify result: true
-----------Schnorr NIZK end-------------
-----------MacWBB start-------------
sk size: 4
sk: [46434447412861395819736421904033263516237479761643850028611036556916607781973 31506132741171721911329936666966367260718076823305152438443852298129490699462 60833970919623133354562418618154882467857170323141656224810009276976298209023 99564111793754186192721845214612516798695389966357248863028398800783234633419]
pk size: 4
pk: [0xc0000fd420 0xc0000fd4a0 0xc0000fd520 0xc0000fd5e0]
mVec(i+5)  0 : 5
mVec(i+5)  1 : 6
mVec(i+5)  2 : 7
mVec size: 3
sigma  0 : [4 242 228 239 141 23 104 171 45 170 111 54 122 183 133 215 72 202 119 39 99 103 31 254 62 91 239 86 73 8 205 0 56 37 199 181 71 204 237 188 226 96 192 134 192 131 25 63 212 8 207 150 108 8 77 40 219 229 225 47 145 156 187 87 179]
sigma  1 : [4 154 186 103 13 32 244 142 66 133 180 95 230 92 251 158 52 130 21 27 140 55 33 35 75 66 99 220 39 236 50 79 33 24 246 17 6 107 98 121 14 129 140 2 223 207 60 182 20 80 37 159 181 204 238 32 163 25 116 250 146 235 137 113 90]
sigma  2 : [4 175 15 28 220 62 94 64 99 55 131 15 89 239 180 227 31 210 194 55 146 226 206 236 226 247 33 63 78 166 116 165 41 4 31 190 56 196 170 74 44 197 24 64 222 52 92 1 96 206 212 250 51 250 148 224 100 160 58 8 245 250 151 165 192]
sigma  3 : [4 36 62 206 69 156 0 93 1 250 102 206 30 70 23 5 91 62 81 95 159 224 51 224 231 113 37 218 10 152 164 119 33 146 219 28 205 144 232 220 0 163 211 129 34 80 227 68 159 69 55 179 148 242 151 96 168 20 61 206 4 48 90 190 233]
sigmas size: 4
Verify result: true
-----------MacWBB end-------------
-----------Umbral Recrypt start-------------
origin message: Hello, Proxy Re-Encryption
Origin key: 0a5f914cd35fc0f3a863fed44741cf12f5e07d1ea3890dd2ef8d956c30cdaa2a
capsule before encode: &{0xc0000690e0 0xc000069110 79834066787074872958791867706688064920113700865471069065778451396624296744082}
capsule after decode: {0xc0001f2860 0xc0001f2be0 79834066787074872958791867706688064920113700865471069065778451396624296744082}
ciphereText: b00eeb87d56c52a0536783e1602e049dac43781758a1732426b6b29f0d89f3e71f3d0ced707bc9f060bc
recreate key: 0a5f914cd35fc0f3a863fed44741cf12f5e07d1ea3890dd2ef8d956c30cdaa2a
rk: 98088047363772239475644965072235645236474817552355435145416873592609756598161
PlainText by my own private key: Hello, Proxy Re-Encryption
plainText: Hello, Proxy Re-Encryption
-----------Umbral Recrypt end-------------
-----------Ringers17 Signature Scheme start-------------
sk size: 5
pk: &{bn256.G2((49669264800538408924629494605233887214326801687935764735879957667131947959981,32054900377537653232131275454890688637482486680313138223544030988958904375296), (41734674735848283981714029716135946391370949387625834031191614747420650686289,51974789225479415249500903122590504624126230315561407938954994932881706836819), (51984352279513858737808192561089394103350601598048354176414560823659261769557,8017200616072249379437810264333163819164013753236904398735157687774339311464)) bn256.G2((10233073010022372351085344847949106796118912878754122692479376217382152415338,3602797831502366208092916118541218394579010910465082323519713221741856556460), (58232751234404998108140560217420006278440267338700832152413068897307834315166,3652612124163725116699085391901735539499912741744362962624560589623535541253), (56674162373692378226209391422442693411355480748770503854027207682894621321428,40275134195001228498556367826055210563829591400348910927115831526505380117043)) [bn256.G2((14236338516523640534116816167171654067808677418873595770858318870102074541674,55052808074860093551950472598120619919260166443885865591626844867385179353373), (16774226931214383101554919878736078547900447372506562865139989380893231620497,3346434753511654437077376040014598616344290518588478110712535690927878359352), (42179118109253703739931248597786598057686238434864971044594475724928958382911,40653407346437039177533553317531983911404599180171951873178247395087648194064)) bn256.G2((63036398243981829854102995697501924108762906431032636878993448325672042079773,54391768534608311875342058055627413056711550001459257004998120256543179555862), (47700944536478024334581356210744302778741901864910848599781770658301308990907,33069257628924823601913006354080259423808089201386525540032740171061106517282), (11147972747844451270031367565835682363626076820464923825233857514935555971254,39589261740700133319336166546572257056303775856879457682619530675895819287574)) bn256.G2((31647739413234688000866903555875201022600948643032053814794466061626731985839,60457650710843293892306808040676350067470559133590779412892790090726674031225), (15491938506942176840935321781174357109371561790052550290072021353602983983935,15338272597681298973667976519664905918213553452359018899495551268860857024308), (58904151459058264831741624243270838830743704923180898515528357989133663043887,56465095500374832268753057686616998420513757723627898359163402010104660180017))] 3 bn256.G2((37848951286614961562061345835589532580265876706740447710253817448755525833094,28797935870480322355967362122276807430559264643475381020460234498400290796544), (41869352989114254997845393872275704300480204789900503155350602766243927415487,19308359780309073298515029528974772626438681571134339480800832667258672430972), (39585619778816699581059127219442615210069715418865119674356537578182842443155,62913926741324377287247523499145308037257295177319161459389100700420950385733))}
sigma: &{58256142834631314966713183908710409313004958501198606916659455254062118129691 bn256.G1(62816302012289028646862870677675658094590634740611790169824891815138990547320, 29167217514794659112428893875285672908401370843375531018508245682180683483606) bn256.G1(51252562952188836388754916350578549676635258853197568518005372677767352937557, 693540157506694639728266588332403333751490330400515925884014248554720366045) [bn256.G1(45565931530492188020803950403484670658603534446200651211288649633889614940531, 9842473872705609329619389560626107284161729747713055115803905626501062528243) bn256.G1(1666339485457583868929265545377367600861701289125138763210468595424834239852, 20582708465860430923762485426403569295027573263321022364271042853123013321984)] 2 bn256.G1(19482193552675954746843608244704246704471814941021154881822513663496416946247, 7784266883963503246062657229965073260666335543297655190968356010636629910385) bn256.G1(13885834342107253478676316236859503238680838483317683377044818868975705597438, 10034821273343775583017466787294662789251295337009105093572688547482210992573)}
Verify result: true
-----------Ringers17 Signature Scheme end-------------
-----------Anonymous Credential start-------------
Credential: &{[3 4 5] 0xc000382000}
attr  0  : 3
attr  1  : 4
attr  2  : 5
Verify origin credential: true
SelectiveCredential: &{0xc0002986e0 0xc0003820a0}
attr  0  : 3
attr  1  : 4
attr  2  : 104702657257102633579772822622124422673143939576486771274630765314225900831707
Verify selective credential result: true
-----------Anonymous Credential end-------------

Thanks!

About

Sher's crypto library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published