code: func CompareHashAndPassword(hash []byte, password []byte) error {
  	// Decode existing hash, retrieve params and salt.
  	params, salt, dk, err := decodeHash(hash)
  	if err != nil {
  		return err
  	}
  
  	// scrypt the cleartext password with the same parameters and salt
  	other, err := scrypt.Key(password, salt, params.N, params.R, params.P, params.DKLen)
  	if err != nil {
  		return err
  	}
  
  	// Constant time comparison
  	if subtle.ConstantTimeCompare(dk, other) == 1 {
  		return nil
  	}
  
  	return ErrMismatchedHashAndPassword
  }
docs: // CompareHashAndPassword compares a derived key with the possible cleartext
  // equivalent. The parameters used in the provided derived key are used.
  // The comparison performed by this function is constant-time. It returns nil
  // on success, and an error if the derived keys do not match.