 @ledger.dongle ?= {}
 _.extend @ledger.dongle,
   States: States
-  Attestation: Attestation
-  BetaAttestation: BetaAttestation
   BitIdRootPath: BitIdRootPath
 
 ###


Firmwares = ledger.dongle.Firmwares

# Ledger OS pubKey, used for pairing.
Attestation =
  String: "04c370d4013107a98dfef01d6db5bb3419deb9299535f0be47f05939a78b314a3c29b51fcaa9b3d46fa382c995456af50cd57fb017c0ce05e4a31864a79b8fbfd6"
Attestation.Bytes = parseInt(hex, 16) for hex in Attestation.String.match(/\w\w/g)
Attestation.xPoint = Attestation.String.substr(2,64)
Attestation.yPoint = Attestation.String.substr(66)

BetaAttestation =
  String: "04e69fd3c044865200e66f124b5ea237c918503931bee070edfcab79a00a25d6b5a09afbee902b4b763ecf1f9c25f82d6b0cf72bce3faf98523a1066948f1a395f"
BetaAttestation.Bytes = parseInt(hex, 16) for hex in BetaAttestation.String.match(/\w\w/g)
BetaAttestation.xPoint = BetaAttestation.String.substr(2,64)
BetaAttestation.yPoint = BetaAttestation.String.substr(66)


# This path do not need a verified PIN to sign messages.

        dataSigBytes = (parseInt(n,16) for n in dataSig.match(/\w\w/g))
        sha = new JSUCrypt.hash.SHA256()
        domain = JSUCrypt.ECFp.getEcDomainByName("secp256k1")
        if isBeta
          Attestation = Attestations["0000000000000000"]
        else
          Attestation = Attestations[result.bytes(0, 8).toString()]
        affinePoint = new JSUCrypt.ECFp.AffinePoint(Attestation.xPoint, Attestation.yPoint)
        pubkey = new JSUCrypt.key.EcFpPublicKey(256, domain, affinePoint)
        ecsig = new JSUCrypt.signature.ECDSA(sha)
        ecsig.init(pubkey, JSUCrypt.signature.MODE_VERIFY)
        if ecsig.verify(dataToSign, dataSigBytes)
          @_attestation = Attestation
          d.resolve(this)
        else
          d.rejectWithError(Errors.DongleNotCertified)
