File tree Expand file tree Collapse file tree 3 files changed +28
-12
lines changed
Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ A JWT (JSON Web Token) library for zig.
55
66### Env
77
8- - Zig >= 0.14.0-dev.2851+b074fb7dd
8+ - Zig >= 0.14.0-dev.3451+d8d2aa9af
99
1010
1111### What the heck is a JWT?
@@ -182,12 +182,21 @@ const p256k_public_key = ecdsa.EcdsaSecp256k1Sha256.PublicKey;
182182
183183// generate p256 public key
184184const p256_kp = ecdsa.EcdsaP256Sha256.KeyPair.generate();
185+ // from plain bytes
186+ const p256_secret_key = try ecdsa.EcdsaP256Sha256.SecretKey.fromBytes(pri_key_buf);
187+ const p256_public_key = try ecdsa.EcdsaP256Sha256.PublicKey.fromSec1(pub_key_bytes);
185188
186189// generate p384 public key
187190const p384_kp = ecdsa.EcdsaP384Sha384.KeyPair.generate();
191+ // from plain bytes
192+ const p384_secret_key = try ecdsa.EcdsaP384Sha384.SecretKey.fromBytes(pri_key_buf);
193+ const p384_public_key = try ecdsa.EcdsaP384Sha384.PublicKey.fromSec1(pub_key_bytes);
188194
189195// generate p256k public key
190196const p256k_kp = ecdsa.EcdsaSecp256k1Sha256.KeyPair.generate();
197+ // from plain bytes
198+ const p256k_secret_key = try ecdsa.EcdsaSecp256k1Sha256.SecretKey.fromBytes(pri_key_buf);
199+ const p256k_public_key = try ecdsa.EcdsaSecp256k1Sha256.PublicKey.fromSec1(pub_key_bytes);
191200~~~
192201
193202EdDSA PublicKey:
@@ -199,6 +208,10 @@ const public_key = Ed25519.PublicKey;
199208
200209// generate public key
201210const kp = Ed25519.KeyPair.generate();
211+
212+ // from plain bytes
213+ const secret_key = try Ed25519.SecretKey.fromBytes(pri_key_buf);
214+ const public_key = try Ed25519.PublicKey.fromBytes(pub_key_buf);
202215~~~
203216
204217
Original file line number Diff line number Diff line change 11.{
2- .name = "zig-jwt" ,
2+ .name = .zig_jwt ,
33 .description = "A JWT (JSON Web Token) library for zig." ,
4- .version = "1.0.16" ,
4+ .version = "1.0.17" ,
5+ .fingerprint = 0x30a5aec248bd7ac3 ,
6+ .minimum_zig_version = "0.14.0-dev.3451+d8d2aa9af" ,
7+ .dependencies = .{},
58 .paths = .{
69 "build.zig" ,
710 "build.zig.zon" ,
Original file line number Diff line number Diff line change @@ -383,21 +383,21 @@ pub const KeyPair = struct {
383383};
384384
385385pub const PrecomputedValues = struct {
386- dp : Fe , // D mod (P-1)
386+ dp : Fe , // D mod (P-1)
387387 dq : Fe , // D mod (Q-1)
388- qinv : Fe , // Q^-1 mod P
388+ qinv : Fe , // Q^-1 mod P
389389
390- // CRTValues is used for the 3rd and subsequent primes. Due to a
391- // historical accident, the CRT for the first two primes is handled
392- // differently in PKCS #1 and interoperability is sufficiently
393- // important that we mirror this.
390+ // CRTValues is used for the 3rd and subsequent primes. Due to a
391+ // historical accident, the CRT for the first two primes is handled
392+ // differently in PKCS #1 and interoperability is sufficiently
393+ // important that we mirror this.
394394 crt_values : [2 ]CRTValue ,
395395};
396396
397397pub const CRTValue = struct {
398- exp : Fe , // D mod (prime-1).
399- coeff : Fe , // R·Coeff ≡ 1 mod Prime.
400- r : Fe , // product of primes prior to this (inc p and q).
398+ exp : Fe , // D mod (prime-1).
399+ coeff : Fe , // R·Coeff ≡ 1 mod Prime.
400+ r : Fe , // product of primes prior to this (inc p and q).
401401};
402402
403403/// Deprecated.
You can’t perform that action at this time.
0 commit comments