Skip to content

Digest in Set coercion but not in Map coercion #25

@ixemad

Description

@ixemad

Hi!

This is a question, and it could also be a bug. I have notice that the coercion of Sets invoke the digest function. However, the coercion of Maps does not. Why is it necessary for Sets but not for Maps? Could it lead to some weakness (collisions) in the hash of Maps?

clojure.lang.IPersistentMap
(-coerce [this md-create-fn write-handlers]
  (if (record? this) ;; BUG somehow records can also trigger the map sometimes (?)
    (let [{:keys [tag value]} (ib/incognito-writer write-handlers this)]
      (encode (:literal magics) (coerce-seq [tag value] md-create-fn write-handlers)))
    (encode (:map magics) (xor-hashes (map #(-coerce % md-create-fn write-handlers) (seq this))))))

clojure.lang.IPersistentSet
(-coerce [this md-create-fn write-handlers]
  (encode (:set magics) (xor-hashes (map #(digest (-coerce % md-create-fn write-handlers)
                                                  md-create-fn)
                                         (seq this)))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions