package org.apache.sshd.common.signature;

import java.util.Map;
import org.apache.sshd.common.session.SessionContext;
import org.apache.sshd.common.util.ValidateUtils;

public class SignatureEd25519 extends AbstractSignature {

    public SignatureEd25519() {
        super("EdDSA");
    }

    @Override
    public boolean verify(SessionContext session, byte[] sig) throws Exception {
        byte[] data = sig;
        Map.Entry<String, byte[]> encoding = extractEncodedSignature(data,
                s -> s.equalsIgnoreCase("ssh-ed25519"));
        if (encoding != null) {
            String keyType = encoding.getKey();
            ValidateUtils.checkTrue("ssh-ed25519".equals(keyType), "Mismatched key type: %s", keyType);
            data = encoding.getValue();
        }
        return doVerify(data);
    }
}
