Jwk class

A JWK (RFC 7517: "JSON Web Key") formatted cryptographic key.

Examples of JSON representation

AES key

final key = Jwt.fromJson({
  "kty": "OKP",
  "d": "{BYTES_IN_BASE64URI}",
});

Ed25519 key

final key = Jwt.fromJson({
  "kty": "OKP",
  "crv": "Ed25519",
  "d": "{BYTES_IN_BASE64URI}",
  "x": "{BYTES_IN_BASE64URI}",
});

P-256 key

final key = Jwt.fromJson({
  "kty": "EC",
  "crv": "P-256",
  "d": "{BYTES_IN_BASE64URI}",
  "x": "{BYTES_IN_BASE64URI}",
  "y": "{BYTES_IN_BASE64URI}",
});

RSA key

final key = Jwt.fromJson({
  "kty": "RSA",
  "n": "{BYTES_IN_BASE64URI}",
  "e": "{BYTES_IN_BASE64URI}",
  "d": "{BYTES_IN_BASE64URI}",
  "q": "{BYTES_IN_BASE64URI}",
  "dp": "{BYTES_IN_BASE64URI}",
  "dq": "{BYTES_IN_BASE64URI}",
  "qi": "{BYTES_IN_BASE64URI}",
})

Constructors

Jwk({String? alg, String? crv, String? cty, List<int>? d, List<int>? dp, List<int>? dq, List<int>? e, String? keyOps, String? kid, String? kty, List<int>? n, List<int>? p, List<int>? q, List<int>? qi, String? use, List<int>? x, List<int>? x5c, List<int>? x5t, String? x5u, List<int>? y})
const

Properties

alg String?
Algorithm of the key.
final
crv String?
Elliptic curve name.
final
cty String?
final
d List<int>?
RSA private key parameter d.
final
dp List<int>?
RSA private key parameter dp.
final
dq List<int>?
RSA private key parameter dq.
final
e List<int>?
RSA exponent. This is public information.
final
hashCode int
The hash code for this object.
no setteroverride
keyOps String?
Operations.
final
kid String?
ID of the key.
final
kty String?
Key type.
final
n List<int>?
RSA modulus. This is public information.
final
p List<int>?
RSA private key parameter p.
final
q List<int>?
RSA private key parameter q.
final
qi List<int>?
RSA private key parameter qi.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
use String?
Use of the key.
final
x List<int>?
Parameter x.
final
x5c List<int>?
X.509 Certificate Chain.
final
x5t List<int>?
X.509 Certificate SHA-1 Thumbprint.
final
x5u String?
X.509 URL.
final
y List<int>?
Parameter y.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toBuilder() JwkBuilder
toJson() Map<String, Object?>
toKeyPair() → KeyPair
toPublicKey() → PublicKey?
toSecretKey() → SecretKey
toString() String
A string representation of this object.
inherited
toUtf8() List<int>

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

fromJson(Map jwk) Jwk
Constructs a private key from decoded JSON tree.
fromKeyPair(KeyPair keyPair) Jwk
fromPublicKey(PublicKey publicKey) Jwk
fromSecretKey(SecretKey secretKey, {required Cipher cipher}) Future<Jwk>
fromUtf8(List<int> bytes) Jwk
Constructs a private key from encoded JSON tree.