github.com/MetalBlockchain/metalgo@v1.11.9/staking/asn1.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package staking
     5  
     6  import (
     7  	"crypto"
     8  	"encoding/asn1"
     9  	"fmt"
    10  
    11  	// Explicitly import for the crypto.RegisterHash init side-effects.
    12  	//
    13  	// Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L30-L34
    14  	_ "crypto/sha256"
    15  )
    16  
    17  var (
    18  	// Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L433-L452
    19  	//
    20  	// RFC 3279, 2.3 Public Key Algorithms
    21  	//
    22  	//	pkcs-1 OBJECT IDENTIFIER ::== { iso(1) member-body(2) us(840)
    23  	//		rsadsi(113549) pkcs(1) 1 }
    24  	//
    25  	// rsaEncryption OBJECT IDENTIFIER ::== { pkcs1-1 1 }
    26  	oidPublicKeyRSA = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1}
    27  	// RFC 5480, 2.1.1 Unrestricted Algorithm Identifier and Parameters
    28  	//
    29  	//	id-ecPublicKey OBJECT IDENTIFIER ::= {
    30  	//		iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 }
    31  	oidPublicKeyECDSA = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1}
    32  )
    33  
    34  func init() {
    35  	if !crypto.SHA256.Available() {
    36  		panic(fmt.Sprintf("required hash %q is not available", crypto.SHA256))
    37  	}
    38  }