"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const kyber_1 = require("@dedis/kyber");
const light_1 = require("protobufjs/light");
const protobuf_1 = require("../protobuf");
const { schnorr } = kyber_1.sign;
const ed25519 = kyber_1.curve.newCurve("edwards25519");
/**
 * Identity of an Ed25519 signer
 */
class IdentityEd25519 extends light_1.Message {
    constructor(props) {
        super(props);
    }
    /**
     * Get the public key as a point
     */
    get public() {
        if (!this._public) {
            this._public = kyber_1.PointFactory.fromProto(this.point);
        }
        return this._public;
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("IdentityEd25519", IdentityEd25519);
    }
    /**
     * Initialize an IdentityEd25519 from a point.
     */
    static fromPoint(p) {
        return new IdentityEd25519({ point: p.toProto() });
    }
    /** @inheritdoc */
    verify(msg, signature) {
        return schnorr.verify(ed25519, this.public, msg, signature);
    }
    /** @inheritdoc */
    toBytes() {
        return this.point;
    }
    /** @inheritdoc */
    toString() {
        return `ed25519:${this.public.toString().toLowerCase()}`;
    }
}
exports.default = IdentityEd25519;
