Class to manage the public key with some userful functions.

### Hierarchy

- Key
  - PublicKey

## Index

### Constructors

- constructor

### Properties

- algorithm
- key
- parameters

### Methods

- computeHash
- isSchemaSupported
- serializeHex
- serializeJson
- verify
- verifyEcDSASignature
- verifyEdDSASignature
- verifySM2Signature
- verifySignature
- deserializeHex

## Constructors

### constructor

- new PublicKey(key: string, algorithm?: KeyType, parameters?: KeyParameters): PublicKey

- Inherited from Key.constructor

  - Defined in crypto/Key.ts:74

  Creates Key.

  If no algorithm or parameters are specified, default values will be used. This is strongly discurraged, because it will forbid using other Key types. Therefore use it only for testing.

  #### Parameters

  - ##### key: string

    Hex encoded key value

  - ##### Optional algorithm: KeyType

    Key type

  - ##### Optional parameters: KeyParameters

    Parameters of the key type

  #### Returns PublicKey

## Properties

### algorithm

algorithm: KeyType

Inherited from Key.algorithm

- Defined in crypto/Key.ts:64

Algorithm used for key generation.

### key

key: string

Inherited from Key.key

- Defined in crypto/Key.ts:74

Key data.

### parameters

parameters: KeyParameters

Inherited from Key.parameters

- Defined in crypto/Key.ts:69

Parameters of the algorithm.

## Methods

### computeHash

- computeHash(msg: string, scheme: SignatureScheme): string

- Inherited from Key.computeHash

  - Defined in crypto/Key.ts:108

  Computes hash of message using hashing function of signature schema.

  #### Parameters

  - ##### msg: string

    Hex encoded input data

  - ##### scheme: SignatureScheme

    Signing schema to use

  #### Returns string

### isSchemaSupported

- isSchemaSupported(schema: SignatureScheme): boolean

- Inherited from Key.isSchemaSupported

  - Defined in crypto/Key.ts:141

  Tests if signing schema is compatible with key type.

  #### Parameters

  - ##### schema: SignatureScheme

    Signing schema to use

  #### Returns boolean

### serializeHex

- serializeHex(): string

- - Defined in crypto/PublicKey.ts:87

  Serializes public key to Hex representation.

  Length definition is not included.

  #### Returns string

### serializeJson

- serializeJson(): JsonKey

- Inherited from Key.serializeJson

  - Defined in crypto/Key.ts:165

  Gets JSON representation of the Key (Public/Private).

  #### Returns JsonKey

### verify

- verify(msg: string, signature: Signature): boolean

- - Defined in crypto/PublicKey.ts:66

  Verifies if the signature was created with private key corresponding to supplied public key and was not tampered with using signature schema.

  #### Parameters

  - ##### msg: string

    Hex encoded input data

  - ##### signature: Signature

    Signature object

  #### Returns boolean

### verifyEcDSASignature

- verifyEcDSASignature(hash: string, signature: string): boolean

- - Defined in crypto/PublicKey.ts:136

  Verifies EcDSA signature of message hash. Curve name is derrived from private key.

  #### Parameters

  - ##### hash: string

    Message hash

  - ##### signature: string

    Hex encoded signature

  #### Returns boolean

### verifyEdDSASignature

- verifyEdDSASignature(hash: string, signature: string): boolean

- - Defined in crypto/PublicKey.ts:150

  Verifies EdDSA signature of message hash. Curve name is derrived from private key.

  #### Parameters

  - ##### hash: string

    Message hash

  - ##### signature: string

    Hex encoded signature

  #### Returns boolean

### verifySM2Signature

- verifySM2Signature(hash: string, signature: string): boolean

- - Defined in crypto/PublicKey.ts:166

  Verifies SM2 signature of message hash.

  Only default SM2 ID is supported.

  #### Parameters

  - ##### hash: string

    Message hash

  - ##### signature: string

    Hex encoded signature

  #### Returns boolean

### verifySignature

- verifySignature(hash: string, signature: string, schema: SignatureScheme): boolean

- - Defined in crypto/PublicKey.ts:109

  For internal use.

  #### Parameters

  - ##### hash: string

    Message hash

  - ##### signature: string

    Hex encoded signature

  - ##### schema: SignatureScheme

    Signature scheme to use

  #### Returns boolean

### Static deserializeHex

- deserializeHex(sr: StringReader, length?: number): PublicKey

- - Defined in crypto/PublicKey.ts:40

  Creates PublicKey from Hex representation.

  #### Parameters

  - ##### sr: StringReader

    String reader

  - ##### Default value length: number = 33

    Byte length of the serialized object

  #### Returns PublicKey

Generated using TypeDoc