Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semcheck regression when accessing a static parameter in proc #14136

Closed
mratsim opened this issue Apr 27, 2020 · 2 comments
Closed

Semcheck regression when accessing a static parameter in proc #14136

mratsim opened this issue Apr 27, 2020 · 2 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Apr 27, 2020

The following used to compile in Nim v1.2.0

type
  MDigest*[bits: static[int]] = object
    ## Message digest type
    data*: array[bits div 8, byte]

  Sha2Context*[bits: static[int],
               bsize: static[int],
               T: uint32|uint64] = object
    count: array[2, T]
    state: array[8, T]
    buffer: array[bsize, byte]

  sha256* = Sha2Context[256, 64, uint32]

template hmacSizeBlock*(h: typedesc): int =
  when (h is Sha2Context):
    int(h.bsize)
  else:
    {.fatal: "Choosen hash primitive is not yet supported!".}

type
  HMAC*[HashType] = object
    ## HMAC context object.
    mdctx: HashType
    opadctx: HashType
    ipad: array[HashType.hmacSizeBlock, byte]
    opad: array[HashType.hmacSizeBlock, byte]

func hkdfExtract*[T;S,I: char|byte](ctx: var HMAC[T],
                     prk: var MDigest[T.bits], # <------- error here "Error: type expected"
                     salt: openArray[S],
                     ikm: openArray[I]
                    ) =
  discard

var ctx: HMAC[sha256]
var prk: MDigest[sha256.bits]
let salt = [byte 0x00, 0x01, 0x02]
let ikm = "CompletelyRandomInput"

ctx.hkdfExtract(prk, salt, ikm)

This is based on nimcrypto and nim-blscurve code. Unfortunately nim-blscurve was deactivated from CI due to a dependency for testing on NimYAML which was broken due to YAML upstream deleting commits from their repo ... (status-im/nim-blscurve#39, flyx/NimYAML#77)

@ghost
Copy link

ghost commented Apr 29, 2020

Git bisect says:
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[10eabec] fix #12864 static params were mutating arg types during sigmatch; fix #12713 ; refs #13529 (#13976)

@Araq
Copy link
Member

Araq commented Apr 29, 2020

Confirmed.

Araq added a commit that referenced this issue May 2, 2020
@Araq Araq closed this as completed in 49b28f1 May 2, 2020
EchoPouet pushed a commit to EchoPouet/Nim that referenced this issue Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants