2019-10-01 13:27:21 +00:00
|
|
|
import * as plugins from './smartcrypto.plugins';
|
|
|
|
|
|
|
|
export class PublicKey {
|
|
|
|
// STATIC
|
|
|
|
public static createFromPrivateKey(pemString: string) {
|
|
|
|
const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
|
|
|
|
return new PublicKey(privateKey);
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:41:34 +00:00
|
|
|
public static fromPemString(pemString: string) {
|
|
|
|
return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
|
|
|
|
}
|
|
|
|
|
2019-10-01 13:27:21 +00:00
|
|
|
// INSTANCE
|
|
|
|
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
|
|
|
|
|
2019-10-01 17:28:50 +00:00
|
|
|
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
|
2019-10-01 13:27:21 +00:00
|
|
|
this.forgePublicKey = publicKeyArg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public toPemString(): string {
|
|
|
|
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
|
|
|
|
}
|
2019-10-01 17:28:50 +00:00
|
|
|
}
|